external-adapters-js
external-adapters-js copied to clipboard
[OPDATA-4855] Added TokenAccount Support for solana-functions
Closes OPDATA-4855
Description
Originally the solana-functions buffer-layout endpoint only supported MintLayout and SanctumPoolStateLayout. It did not support Token account programs. This change is to add support to deserialize and support Token Accounts
Changes
Implemented: https://solana-labs.github.io/solana-program-library/token/js/variables/AccountLayout.html
Steps to Test
Token Account:
chrayzhang@MB-C3H04RT9WT ~ % curl -X POST http://localhost:8080 \
-H "Content-Type: application/json" \
-d '{
"data": {
"endpoint": "buffer-layout",
"field": "amount",
"stateAccountAddress": "FvkbfMm98jefJWrqkvXvsSZ9RFaRBae8k6c1jaYA5vY3"
}
}' | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 497 100 336 100 161 271 130 0:00:01 0:00:01 --:--:-- 401
{
"data": {
"result": "34228815152"
},
"statusCode": 200,
"result": "34228815152",
"timestamps": {
"providerDataRequestedUnixMs": 1764628385812,
"providerDataReceivedUnixMs": 1764628386096
},
"meta": {
"adapterName": "SOLANA_FUNCTIONS",
"metrics": {
"feedId": "{\"stateAccountAddress\":\"fvkbfmm98jefjwrqkvxvssz9rfarbae8k6c1jaya5vy3\",\"field\":\"amount\"}"
}
}
}
Mint account:
chrayzhang@MB-C3H04RT9WT ~ % curl -X POST http://localhost:8080 \
-H "Content-Type: application/json" \
-d '{
"data": {
"endpoint": "buffer-layout",
"field": "supply",
"stateAccountAddress": "3b8X44fLF9ooXaUm3hhSgjpmVs6rZZ3pPoGnGahc3Uu7"
}
}' | jq
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 497 100 336 100 161 1635 783 --:--:-- --:--:-- --:--:-- 2424
{
"data": {
"result": "34156329357"
},
"statusCode": 200,
"result": "34156329357",
"timestamps": {
"providerDataRequestedUnixMs": 1764628429970,
"providerDataReceivedUnixMs": 1764628430044
},
"meta": {
"adapterName": "SOLANA_FUNCTIONS",
"metrics": {
"feedId": "{\"stateAccountAddress\":\"3b8x44flf9ooxaum3hhsgjpmvs6rzz3ppogngahc3uu7\",\"field\":\"supply\"}"
}
}
}
Quality Assurance
- [ x] If a new adapter was made, or an existing one was modified so that its environment variables have changed, update the relevant
infra-k8sconfiguration file. - [ x] If a new adapter was made, or an existing one was modified so that its environment variables have changed, update the relevant
adapter-secretsconfiguration file. - [ x] If a new adapter was made, or a new endpoint was added, update the
test-payload.jsonfile with relevant requests. - [ x] The branch naming follows git flow (
feature/x,chore/x,release/x,hotfix/x,fix/x) or is created from Jira. - [ x] This is related to a maximum of one Jira story or GitHub issue.
- [ x] Types are safe (avoid TypeScript/TSLint features like any and disable, instead use more specific types).
- [ x] All code changes have 100% unit and integration test coverage. If testing is not applicable or too difficult to justify doing, the reasoning should be documented explicitly in the PR.