diff --git a/.env.prod b/.env.prod index c8d914ec..12204566 100644 --- a/.env.prod +++ b/.env.prod @@ -1,5 +1,5 @@ PAYER_KEYPAIR="op://Solana Dev/Solana Program Keys/devnet-authority" -M_MINT_KEYPAIR="op://Solana Dev/Solana Program Keys/mint-mainnet" +M_MINT_KEYPAIR="op://Solana Dev/Solana Program Keys/m-mint-mainnet-old" WM_MINT_KEYPAIR="op://Solana Dev/Solana Program Keys/wm-mint" M_MINT_MULTISIG_KEYPAIR="op://Solana Dev/Solana Program Keys/token-multisig" RPC_URL="op://Solana Dev/Helius/prod rpc" diff --git a/dashboard/package.json b/dashboard/package.json index bfcddf96..7bf53fda 100644 --- a/dashboard/package.json +++ b/dashboard/package.json @@ -20,7 +20,7 @@ }, "devDependencies": { "@eslint/js": "^9.21.0", - "@m0-foundation/solana-m-api-sdk": "0.1.7", + "@m0-foundation/solana-m-api-sdk": "0.1.9", "@m0-foundation/solana-m-sdk": "0.2.5", "@reown/appkit": "^1.7.2", "@reown/appkit-adapter-solana": "^1.7.2", diff --git a/dashboard/src/components/swap.tsx b/dashboard/src/components/swap.tsx index 07208298..8b619044 100644 --- a/dashboard/src/components/swap.tsx +++ b/dashboard/src/components/swap.tsx @@ -144,7 +144,7 @@ export const Swap = ({ mode }: { mode: SwapMode }) => { try { setIsLoading(true); - const quote = await ApiClient.swap.quote({ + const quote = await ApiClient.transactions.quote({ inputMint: fromAsset.mint.toBase58(), outputMint: toAsset.mint.toBase58(), amount: new Decimal(debouncedAmount).mul(10 ** fromAsset.decimals).toString(), @@ -170,7 +170,7 @@ export const Swap = ({ mode }: { mode: SwapMode }) => { throw new Error('No wallet connected'); } - const swap = await ApiClient.swap.swap({ + const swap = await ApiClient.transactions.swap({ quoteId: quote.quoteId, userPublicKey: walletProvider.publicKey.toBase58(), }); diff --git a/package.json b/package.json index c428ac1c..d2147354 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "cli:dev": "op run --account mzerolabs.1password.com --env-file='./.env.dev' --no-masking -- ts-node services/cli/main.ts", "cli:prod": "op run --account mzerolabs.1password.com --env-file='./.env.prod' -- ts-node services/cli/main.ts", "cli:test": "op run --account mzerolabs.1password.com --env-file='./.env.dev' -- ts-node services/cli/test.ts", - "fb:dev": "op run --account mzerolabs.1password.com --env-file='./.env.dev' -- ts-node services/cli/fb.ts" + "fb:dev": "op run --account mzerolabs.1password.com --env-file='./.env.dev' -- ts-node services/cli/fb.ts", + "repl:prod": "cd services/repl && npm run build && clear && op run --no-masking --account mzerolabs.1password.com --env-file='../../.env.prod' -- node dist/cli.js" }, "devDependencies": { "ts-node": "~10.9.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b8b4e8e9..a17cd194 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -112,8 +112,8 @@ importers: specifier: ^9.21.0 version: 9.29.0 '@m0-foundation/solana-m-api-sdk': - specifier: 0.1.7 - version: 0.1.7 + specifier: 0.1.9 + version: 0.1.9 '@m0-foundation/solana-m-sdk': specifier: 0.2.5 version: 0.2.5(bufferutil@4.0.9)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.8.3)(utf-8-validate@5.0.10)(zod@3.25.67) @@ -326,9 +326,18 @@ importers: '@solana/kit': specifier: ^2.1.1 version: 2.1.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.8.3)(ws@8.18.2(bufferutil@4.0.9)(utf-8-validate@5.0.10)) + '@solana/spl-token': + specifier: 'catalog:' + version: 0.4.13(@solana/web3.js@1.98.2(bufferutil@4.0.9)(typescript@5.8.3)(utf-8-validate@5.0.10))(bufferutil@4.0.9)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.8.3)(utf-8-validate@5.0.10) '@solana/web3.js': specifier: 'catalog:' version: 1.98.2(bufferutil@4.0.9)(typescript@5.8.3)(utf-8-validate@5.0.10) + '@wormhole-foundation/sdk': + specifier: 'catalog:' + version: 1.16.1(@types/react@19.1.8)(axios@1.9.0)(bufferutil@4.0.9)(got@11.8.6)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)(typescript@5.8.3)(utf-8-validate@5.0.10) + '@wormhole-foundation/sdk-solana-ntt': + specifier: 'catalog:' + version: 0.7.0-multi-transceiver-alpha.1(@wormhole-foundation/sdk-base@1.16.1)(@wormhole-foundation/sdk-definitions@1.16.1)(@wormhole-foundation/sdk-solana-core@1.16.1(bufferutil@4.0.9)(typescript@5.8.3)(utf-8-validate@5.0.10))(@wormhole-foundation/sdk-solana@1.16.1(bufferutil@4.0.9)(typescript@5.8.3)(utf-8-validate@5.0.10))(bufferutil@4.0.9)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.8.3)(utf-8-validate@5.0.10) apicache: specifier: ^1.6.3 version: 1.6.3 @@ -454,6 +463,40 @@ importers: specifier: 'catalog:' version: 6.1.3 + services/repl: + dependencies: + '@inkjs/ui': + specifier: ^2.0.0 + version: 2.0.0(ink@4.4.1(@types/react@18.3.23)(bufferutil@4.0.9)(react@18.3.1)(utf-8-validate@5.0.10)) + '@m0-foundation/solana-m-api-sdk': + specifier: 0.1.9 + version: 0.1.9 + '@solana/spl-token': + specifier: 'catalog:' + version: 0.4.13(@solana/web3.js@1.98.2(bufferutil@4.0.9)(typescript@5.8.3)(utf-8-validate@5.0.10))(bufferutil@4.0.9)(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.8.3)(utf-8-validate@5.0.10) + '@solana/web3.js': + specifier: 'catalog:' + version: 1.98.2(bufferutil@4.0.9)(typescript@5.8.3)(utf-8-validate@5.0.10) + ink: + specifier: ^4.4.1 + version: 4.4.1(@types/react@18.3.23)(bufferutil@4.0.9)(react@18.3.1)(utf-8-validate@5.0.10) + react: + specifier: ^18.3.1 + version: 18.3.1 + react-query: + specifier: ^3.39.3 + version: 3.39.3(react@18.3.1) + devDependencies: + '@types/react': + specifier: ^18.0.32 + version: 18.3.23 + ts-node: + specifier: ^10.9.1 + version: 10.9.2(@swc/core@1.12.3(@swc/helpers@0.5.17))(@types/node@22.15.3)(typescript@5.8.3) + typescript: + specifier: ^5.0.3 + version: 5.8.3 + services/shared: dependencies: '@m0-foundation/solana-m-sdk': @@ -617,6 +660,10 @@ packages: '@adraffy/ens-normalize@1.11.0': resolution: {integrity: sha512-/3DDPKHqqIqxUULp8yP4zODUY1i+2xvVWsv8A79xGWdCAG+8sb0hRh0Rk2QyOJUnnbyPUAZYcpBuRe3nS2OIUg==} + '@alcalzone/ansi-tokenize@0.1.3': + resolution: {integrity: sha512-3yWxPTq3UQ/FY9p1ErPxIyfT64elWaMvM9lIHnaqpyft63tkxodF5aUElYHrdisWve5cETkh1+KBw1yJuW0aRw==} + engines: {node: '>=14.13.1'} + '@ampproject/remapping@2.3.0': resolution: {integrity: sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==} engines: {node: '>=6.0.0'} @@ -1448,6 +1495,12 @@ packages: '@injectivelabs/utils@1.15.30': resolution: {integrity: sha512-DOtqrz7CDlApXYSbvkg9Gy53GJA8JBLmrdam/BUj6BfL32H7RcSDzEMiKqAIdsGASU1R4B4IJrfzCdhHeDUHZg==} + '@inkjs/ui@2.0.0': + resolution: {integrity: sha512-5+8fJmwtF9UvikzLfph9sA+LS+l37Ij/szQltkuXLOAXwNkBX9innfzh4pLGXIB59vKEQUtc6D4qGvhD7h3pAg==} + engines: {node: '>=18'} + peerDependencies: + ink: '>=5' + '@isaacs/cliui@8.0.2': resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==} engines: {node: '>=12'} @@ -1603,8 +1656,8 @@ packages: '@m0-foundation/solana-m-api-sdk@0.1.3': resolution: {integrity: sha512-q4bg5KJ4jcp8Zs96nPcA2G80ANSvat09XM0CybOOXFbLRD66XzPKtwxsw+bICKNTSr/j+L2+mvRZo5mtFOLDxA==} - '@m0-foundation/solana-m-api-sdk@0.1.7': - resolution: {integrity: sha512-fjdycOrVpcP9H1gck3CafHF26xmvgOC7bKgB2IQfVC6iXu5EF9RQkmfpuWOrH/B7SCRqXstUCSM3SG4Ps2A7KA==} + '@m0-foundation/solana-m-api-sdk@0.1.9': + resolution: {integrity: sha512-NT+yCWkNDP0O61Vyg1EG4nIRFj8KfROOmRYrn9hhyGFhVrhfE6U7AvBm7SFI9IpbQf3UA4WNQXWSbggsL+zJvQ==} '@m0-foundation/solana-m-sdk@0.2.5': resolution: {integrity: sha512-KgUdPUsayRXU1SGnRh4XMpuFIODkKsQm2XI9gt29FMtbJQcAvMbP/fs45IRl99mU9p1ueCmcXbxM5OZHdMUf/A==} @@ -3414,6 +3467,9 @@ packages: '@types/pbkdf2@3.1.2': resolution: {integrity: sha512-uRwJqmiXmh9++aSu1VNEn3iIxWOhd8AHXNSdlaLfdAAdSTY9jYVeGWnzejM3dvrkbqE3/hyQkQQ29IFATEGlew==} + '@types/prop-types@15.7.15': + resolution: {integrity: sha512-F6bEyamV9jKGAFBEmlQnesRPGOQqS2+Uwi0Em15xenOxHaf2hv6L8YCVn3rPdPJOiJfPiCnLIRyvwVaqMY3MIw==} + '@types/qs@6.9.8': resolution: {integrity: sha512-u95svzDlTysU5xecFNTgfFG5RUWu1A9P0VzgpcIiGZA9iraHOdSzcxMxQ55DyeRaGCSxQi7LxXDI4rzq/MYfdg==} @@ -3425,6 +3481,9 @@ packages: peerDependencies: '@types/react': ^19.0.0 + '@types/react@18.3.23': + resolution: {integrity: sha512-/LDXMQh55EzZQ0uVAZmKKhfENivEvWz6E+EYzh+/MCjMhNsotd+ZHhBGIjFDTi6+fz0OhQQQLbTgdQIxxCsC0w==} + '@types/react@19.1.8': resolution: {integrity: sha512-AwAfQ2Wa5bCx9WP8nZL2uMZWod7J7/JSplxbTmBQ5ms6QpqNYm672H0Vu9ZVKVngQ+ii4R/byguVEUZQyeg44g==} @@ -3989,6 +4048,10 @@ packages: resolution: {integrity: sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==} engines: {node: '>=8'} + ansi-escapes@6.2.1: + resolution: {integrity: sha512-4nJ3yixlEthEJ9Rk4vPcdBRkZvQZlYyu8j4/Mqz5sgIkddmEnH2Yj2ZrnP9S3tQOvSNRUIgVNF/1yPpRAGNRig==} + engines: {node: '>=14.16'} + ansi-regex@5.0.1: resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} engines: {node: '>=8'} @@ -4065,6 +4128,10 @@ packages: resolution: {integrity: sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==} engines: {node: '>=8.0.0'} + auto-bind@5.0.1: + resolution: {integrity: sha512-ooviqdwwgfIfNmDwo94wlshcdzfO64XV0Cg6oDsDYBJfITDz1EngD2z7DkbvCWn+XIMsIqW27sEVF6qcpJrRcg==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + available-typed-arrays@1.0.7: resolution: {integrity: sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==} engines: {node: '>= 0.4'} @@ -4228,6 +4295,9 @@ packages: resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} engines: {node: '>=8'} + broadcast-channel@3.7.0: + resolution: {integrity: sha512-cIAKJXAxGJceNZGTZSBzMxzyOn72cVgPnKx4dc6LRjQgbaJUQqhy5rzL3zbMxkMWsGKkv2hSFkPRMEXfoMZ2Mg==} + brorand@1.1.0: resolution: {integrity: sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==} @@ -4389,8 +4459,8 @@ packages: resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} engines: {node: '>=10'} - chalk@5.4.1: - resolution: {integrity: sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w==} + chalk@5.6.0: + resolution: {integrity: sha512-46QrSQFyVSEyYAgQ22hQ+zDa60YHA4fBstHmtSApj1Y5vKtG27fWowW03jCk5KcbXEWPZUIR894aARCA/G1kfQ==} engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} char-regex@1.0.2: @@ -4420,6 +4490,22 @@ packages: cjs-module-lexer@1.4.3: resolution: {integrity: sha512-9z8TZaGM1pfswYeXrUpzPrkx8UnWYdhJclsiYMm6x/w5+nN+8Tf/LnAgfLGQCm59qAOxU8WwHEq2vNwF6i4j+Q==} + cli-boxes@3.0.0: + resolution: {integrity: sha512-/lzGpEWL/8PfI0BmBOPRwp0c/wFNX1RdUML3jK/RcSBA9T8mZDdQpqYBKtCFTOfQbwPqWEOpjqW+Fnayc0969g==} + engines: {node: '>=10'} + + cli-cursor@4.0.0: + resolution: {integrity: sha512-VGtlMu3x/4DOtIUwEkRezxUZ2lBacNJCHash0N0WeZDBS+7Ux1dm3XWAgWYxLJFMMdOeXMHXorshEFhbMSGelg==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + + cli-spinners@3.2.0: + resolution: {integrity: sha512-pXftdQloMZzjCr3pCTIRniDcys6dDzgpgVhAHHk6TKBDbRuP1MkuetTF5KSv4YUutbOPa7+7ZrAJ2kVtbMqyXA==} + engines: {node: '>=18.20'} + + cli-truncate@3.1.0: + resolution: {integrity: sha512-wfOBkjXteqSnI59oPcJkcPl/ZmwvMMOj340qUIY1SKZCv0B9Cf4D4fAucRkIKQmsIuYK3x1rrgU7MeGRruiuiA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + client-only@0.0.1: resolution: {integrity: sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==} @@ -4449,6 +4535,10 @@ packages: resolution: {integrity: sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==} engines: {iojs: '>= 1.0.0', node: '>= 0.12.0'} + code-excerpt@4.0.0: + resolution: {integrity: sha512-xxodCmBen3iy2i0WtAK8FlFNrRzjUqjRsMfho58xT/wvZU1YTM3fCnRjcy1gJPMepaRlgm/0e6w8SpWHpn3/cA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + collect-v8-coverage@1.0.2: resolution: {integrity: sha512-lHl4d5/ONEbLlJvaJNtsF/Lz+WvB07u2ycqTYbdrq7UypDXailES4valYb2eWiJFxZlVmpGekfqoxQhzyFdT4Q==} @@ -4521,6 +4611,10 @@ packages: convert-source-map@2.0.0: resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} + convert-to-spaces@2.0.1: + resolution: {integrity: sha512-rcQ1bsQO9799wq24uE5AM2tAILy4gXGIK/njFWcVQkGNZ96edlpY+A7bjwvzjYvLDyzmG1MmMLZhpcsb+klNMQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + cookie-es@1.2.2: resolution: {integrity: sha512-+W7VmiVINB+ywl1HGXJXmrqkOhpKrIiVZV6tQuV54ZyQC7MMuBt81Vc336GMLoHBq5hV/F9eXgt5Mnx0Rha5Fg==} @@ -4763,6 +4857,9 @@ packages: resolution: {integrity: sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==} engines: {node: '>=8'} + detect-node@2.1.0: + resolution: {integrity: sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g==} + diff-sequences@29.6.3: resolution: {integrity: sha512-EjePK1srD3P08o2j4f0ExnylqRs5B9tJjcp9t1krH2qRi8CCdsYfwe9JgSLurFBWwq4uOlipzfk5fHNvwFKr8Q==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} @@ -5122,6 +5219,10 @@ packages: fecha@4.2.3: resolution: {integrity: sha512-OP2IUU6HeYKJi3i0z4A19kHMQoLVs4Hc+DPqqxI2h/DPZHTm/vjsfC6P0b4jCMy14XizLBqvndQ+UilD7707Jw==} + figures@6.1.0: + resolution: {integrity: sha512-d+l3qxjSesT4V7v2fh+QnmFnUWv9lSpjarhShNTgBOfA0ttejbQUAlHLitbjkoRiDulW0OPoQPYIGhIC8ohejg==} + engines: {node: '>=18'} + file-entry-cache@8.0.0: resolution: {integrity: sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==} engines: {node: '>=16.0.0'} @@ -5411,6 +5512,10 @@ packages: resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==} engines: {node: '>=0.8.19'} + indent-string@5.0.0: + resolution: {integrity: sha512-m6FAo/spmsW2Ab2fU35JTYwtOKa2yAwXSwgjSv1TJzh4Mh7mC3lzAOVLBprb72XsTrgkEIsl7YrFNAiDiRhIGg==} + engines: {node: '>=12'} + inflight@1.0.6: resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==} deprecated: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful. @@ -5418,6 +5523,19 @@ packages: inherits@2.0.4: resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} + ink@4.4.1: + resolution: {integrity: sha512-rXckvqPBB0Krifk5rn/5LvQGmyXwCUpBfmTwbkQNBY9JY8RSl3b8OftBNEYxg4+SWUhEKcPifgope28uL9inlA==} + engines: {node: '>=14.16'} + peerDependencies: + '@types/react': '>=18.0.0' + react: '>=18.0.0' + react-devtools-core: ^4.19.1 + peerDependenciesMeta: + '@types/react': + optional: true + react-devtools-core: + optional: true + int64-buffer@1.1.0: resolution: {integrity: sha512-94smTCQOvigN4d/2R/YDjz8YVG0Sufvv2aAh8P5m42gwhCsDAJqnbNOrxJsrADuAFAA69Q/ptGzxvNcNuIJcvw==} @@ -5465,6 +5583,10 @@ packages: resolution: {integrity: sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==} engines: {node: '>= 0.4'} + is-ci@3.0.1: + resolution: {integrity: sha512-ZYvCgrefwqoQ6yTyYUbQu64HsITZ3NfKX1lzaEYdkTDcfKzzCI/wthRRYKkdjHKFVgNiXKAKm65Zo1pk2as/QQ==} + hasBin: true + is-core-module@2.16.1: resolution: {integrity: sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==} engines: {node: '>= 0.4'} @@ -5477,6 +5599,10 @@ packages: resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} engines: {node: '>=8'} + is-fullwidth-code-point@4.0.0: + resolution: {integrity: sha512-O4L094N2/dZ7xqVdrXhh9r1KODPJpFms8B5sGdJLPy664AgvXsreZUyCQQNItZRDlYug4xStLjNp/sz3HvBowQ==} + engines: {node: '>=12'} + is-generator-fn@2.1.0: resolution: {integrity: sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==} engines: {node: '>=6'} @@ -5489,6 +5615,9 @@ packages: resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} engines: {node: '>=0.10.0'} + is-lower-case@2.0.2: + resolution: {integrity: sha512-bVcMJy4X5Og6VZfdOZstSexlEy20Sr0k/p/b2IlQJlfdKAQuMpiv5w2Ccxb8sKdRUNAG1PnHVHjFSdRDVS6NlQ==} + is-nan@1.3.2: resolution: {integrity: sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w==} engines: {node: '>= 0.4'} @@ -5519,6 +5648,13 @@ packages: resolution: {integrity: sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ==} engines: {node: '>= 0.4'} + is-unicode-supported@2.1.0: + resolution: {integrity: sha512-mE00Gnza5EEB3Ds0HfMyllZzbBrmLOX3vfWoj9A9PEnTfratQ/BcaJOuMhnkhjXvb2+FkY3VuHqtAGpTPmglFQ==} + engines: {node: '>=18'} + + is-upper-case@2.0.2: + resolution: {integrity: sha512-44pxmxAvnnAOwBg4tHPnkfvgjPwbc5QIsSstNU+YcJ1ovxVzCWpSGosPJOZh/a1tdl81fbgnLc9LLv+x2ywbPQ==} + isarray@1.0.0: resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==} @@ -6071,6 +6207,9 @@ packages: resolution: {integrity: sha512-hdN1wVrZbb29eBGiGjJbeP8JbKjq1urkHJ/LIP/NY48MZ1QVXUsQBV1G1zvYFHn1XE06cwjBsOI2K3Ulnj1YXQ==} engines: {node: '>=8'} + match-sorter@6.3.4: + resolution: {integrity: sha512-jfZW7cWS5y/1xswZo8VBOdudUiSd9nifYRWphc9M5D/ee4w4AoXLgBEdRbgVaxbMuagBPeUC5y2Hi8DO6o9aDg==} + math-intrinsics@1.1.0: resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==} engines: {node: '>= 0.4'} @@ -6106,6 +6245,9 @@ packages: resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==} engines: {node: '>=8.6'} + microseconds@0.2.0: + resolution: {integrity: sha512-n7DHHMjR1avBbSpsTBj6fmMGh2AGrifVV4e+WYc3Q9lO+xnSZ3NyhcBND3vzzatt05LFhoKFRxrIyklmLlUtyA==} + miller-rabin@4.0.1: resolution: {integrity: sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==} hasBin: true @@ -6217,6 +6359,9 @@ packages: nan@2.22.2: resolution: {integrity: sha512-DANghxFkS1plDdRsX0X9pm0Z6SJNN6gBdtXfanwoZ8hooC5gosGFSBGRYHUVPz1asKA/kMRqDRdHrluZ61SpBQ==} + nano-time@1.0.0: + resolution: {integrity: sha512-flnngywOoQ0lLQOTRNexn2gGSNuM9bKj9RZAWSzhQ+UJYaAFG9bac4DW9VHjUAzrOaIcajHybCTHe/bkvozQqA==} + nanoid@3.3.11: resolution: {integrity: sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} @@ -6343,6 +6488,9 @@ packages: resolution: {integrity: sha512-nK28WOo+QIjBkDduTINE4JkF/UJJKyf2EJxvJKfblDpyg0Q+pkOHNTL0Qwy6NP6FhE/EnzV73BxxqcJaXY9anw==} engines: {node: '>= 0.4'} + oblivious-set@1.0.0: + resolution: {integrity: sha512-z+pI07qxo4c2CulUHCDf9lcqDlMSo72N/4rLUpRXf6fu+q8vjt8y0xS+Tlf8NTJDdTXHbdeO1n3MlbctwEoXZw==} + oblivious-set@1.4.0: resolution: {integrity: sha512-szyd0ou0T8nsAqHtprRcP3WidfsN1TnAR5yWXf2mFCEr5ek3LEOkT6EZ/92Xfs74HIdyhG5WkGxIssMU0jBaeg==} engines: {node: '>=16'} @@ -6461,6 +6609,10 @@ packages: resolution: {integrity: sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==} engines: {node: '>= 0.8'} + patch-console@2.0.0: + resolution: {integrity: sha512-0YNdUceMdaQwoKce1gatDScmMo5pu/tfABfnzEqeG0gtTmd7mh/WcwgUjtAeOU7N8nFFlbQBnFK2gXW5fGvmMA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + path-browserify@1.0.1: resolution: {integrity: sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==} @@ -6747,6 +6899,24 @@ packages: react: ~16 react-dom: ~16 + react-query@3.39.3: + resolution: {integrity: sha512-nLfLz7GiohKTJDuT4us4X3h/8unOh+00MLb2yJoGTPjxKs2bc1iDhkNx2bd5MKklXnOD3NrVZ+J2UXujA5In4g==} + peerDependencies: + react: ^16.8.0 || ^17.0.0 || ^18.0.0 + react-dom: '*' + react-native: '*' + peerDependenciesMeta: + react-dom: + optional: true + react-native: + optional: true + + react-reconciler@0.29.2: + resolution: {integrity: sha512-zZQqIiYgDCTP/f1N/mAR10nJGrPD2ZR+jDSEsKWJHYC7Cm2wodlwbR3upZRdC3cjIjSlTLNVyO7Iu0Yy7t2AYg==} + engines: {node: '>=0.10.0'} + peerDependencies: + react: ^18.3.1 + react-router-dom@7.6.2: resolution: {integrity: sha512-Q8zb6VlTbdYKK5JJBLQEN06oTUa/RAbG/oQS1auK1I0TbJOXktqm+QENEVJU6QvWynlXPRBXI3fiOQcSEA78rA==} engines: {node: '>=20.0.0'} @@ -6782,6 +6952,10 @@ packages: react: '>=16.6.0' react-dom: '>=16.6.0' + react@18.3.1: + resolution: {integrity: sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==} + engines: {node: '>=0.10.0'} + react@19.1.0: resolution: {integrity: sha512-FS+XFBNvn3GTAWq26joslQgWNoFu08F4kl0J4CgdNKADkdSGXQyTCnKteIAJy96Br6YbpEU1LSzV5dYtjMkMDg==} engines: {node: '>=0.10.0'} @@ -6837,6 +7011,9 @@ packages: react: optional: true + remove-accents@0.5.0: + resolution: {integrity: sha512-8g3/Otx1eJaVD12e31UbJj1YzdtVvzH85HV7t+9MJYk/u3XmkOUJ5Ys9wQrf9PCPK8+xn4ymzqYCiZl6QWKn+A==} + require-addon@1.1.0: resolution: {integrity: sha512-KbXAD5q2+v1GJnkzd8zzbOxchTkStSyJZ9QwoCq3QwEXAaIlG3wDYRZGzVD357jmwaGY7hr5VaoEAL0BkF0Kvg==} engines: {bare: '>=1.10.0'} @@ -6875,10 +7052,19 @@ packages: responselike@2.0.1: resolution: {integrity: sha512-4gl03wn3hj1HP3yzgdI7d3lCkF95F21Pz4BPGvKHinyQzALR5CapwC8yIi0Rh58DEMQ/SguC03wFj2k0M/mHhw==} + restore-cursor@4.0.0: + resolution: {integrity: sha512-I9fPXU9geO9bHOt9pHHOhOkYerIMsmVaWB0rA2AI9ERh/+x/i7MV5HKBNrg+ljO5eoPVgCcnFuRjJ9uH6I/3eg==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + reusify@1.1.0: resolution: {integrity: sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==} engines: {iojs: '>=1.0.0', node: '>=0.10.0'} + rimraf@3.0.2: + resolution: {integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==} + deprecated: Rimraf versions prior to v4 are no longer supported + hasBin: true + ripemd160@2.0.2: resolution: {integrity: sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==} @@ -6945,6 +7131,9 @@ packages: peerDependencies: '@solana/web3.js': ^1.44.3 + scheduler@0.23.2: + resolution: {integrity: sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==} + scheduler@0.26.0: resolution: {integrity: sha512-NlHwttCI/l5gCPR3D1nNXtWABUmBwvZpEQiD4IXSbIDq8BzLIK/7Ir5gTFSGZDUu37K5cMNp0hFtzO38sC7gWA==} @@ -7060,6 +7249,14 @@ packages: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} engines: {node: '>=8'} + slice-ansi@5.0.0: + resolution: {integrity: sha512-FC+lgizVPfie0kkhqUScwRu1O/lF6NOgJmlCgK+/LYxDCTk8sGelYaHDhFcDN+Sn3Cv+3VSa4Byeo+IMCzpMgQ==} + engines: {node: '>=12'} + + slice-ansi@6.0.0: + resolution: {integrity: sha512-6bn4hRfkTvDfUoEQYkERg0BVF1D0vrX9HEkMl08uDiNWvVvjylLHvZFZWkDo6wjT8tUctbYl1nCOuE66ZTaUtA==} + engines: {node: '>=14.16'} + smart-buffer@4.2.0: resolution: {integrity: sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==} engines: {node: '>= 6.0.0', npm: '>= 3.0.0'} @@ -7435,6 +7632,10 @@ packages: resolution: {integrity: sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==} engines: {node: '>=4'} + type-fest@0.12.0: + resolution: {integrity: sha512-53RyidyjvkGpnWPMF9bQgFtWp+Sl8O2Rp13VavmJgfAP9WWG6q6TkrKU8iyJdnwnfgHI6k2hTlgqH4aSdjoTbg==} + engines: {node: '>=10'} + type-fest@0.21.3: resolution: {integrity: sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==} engines: {node: '>=10'} @@ -7503,6 +7704,9 @@ packages: unidragger@3.0.1: resolution: {integrity: sha512-RngbGSwBFmqGBWjkaH+yB677uzR95blSQyxq6hYbrQCejH3Mx1nm8DVOuh3M9k2fQyTstWUG5qlgCnNqV/9jVw==} + unload@2.2.0: + resolution: {integrity: sha512-B60uB5TNBLtN6/LsgAf3udH9saB5p7gqJwcFfbOEZ8BcBHnGwCf6G/TGiEqkRAxX7zAFIUtzdrXQSdL3Q/wqNA==} + unload@2.4.1: resolution: {integrity: sha512-IViSAm8Z3sRBYA+9wc0fLQmU9Nrxb16rcDmIiR6Y9LJSZzI7QY5QsDhqPpKOjAn0O9/kfK1TfNEMMAGPTIraPw==} @@ -7884,6 +8088,10 @@ packages: engines: {node: '>= 8'} hasBin: true + widest-line@4.0.1: + resolution: {integrity: sha512-o0cyEG0e8GPzT4iGHphIOh0cJOV8fivsXxddQasHPHfoZf1ZexrfeA21w2NaEN1RHE+fXlfISmOE8R9N3u3Qig==} + engines: {node: '>=12'} + wif@5.0.0: resolution: {integrity: sha512-iFzrC/9ne740qFbNjTZ2FciSRJlHIXoxqk/Y5EnE08QOXu1WjJyCCswwDTYbohAOEnlCtLaAAQBhyaLRFh2hMA==} @@ -8039,6 +8247,9 @@ packages: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} engines: {node: '>=10'} + yoga-wasm-web@0.3.3: + resolution: {integrity: sha512-N+d4UJSJbt/R3wqY7Coqs5pcV0aUj2j9IaQ3rNj9bVCLld8tTGKRa2USARjnvZJWVx1NDmQev8EknoczaOQDOA==} + zen-observable-ts@1.2.5: resolution: {integrity: sha512-QZWQekv6iB72Naeake9hS1KxHlotfRpe+WGNbNx5/ta+R3DNjVO2bswf63gXlWDcs+EMd7XY8HfVQyP1X6T4Zg==} @@ -8085,6 +8296,11 @@ snapshots: '@adraffy/ens-normalize@1.11.0': {} + '@alcalzone/ansi-tokenize@0.1.3': + dependencies: + ansi-styles: 6.2.1 + is-fullwidth-code-point: 4.0.0 + '@ampproject/remapping@2.3.0': dependencies: '@jridgewell/gen-mapping': 0.3.8 @@ -9122,6 +9338,14 @@ snapshots: transitivePeerDependencies: - debug + '@inkjs/ui@2.0.0(ink@4.4.1(@types/react@18.3.23)(bufferutil@4.0.9)(react@18.3.1)(utf-8-validate@5.0.10))': + dependencies: + chalk: 5.6.0 + cli-spinners: 3.2.0 + deepmerge: 4.3.1 + figures: 6.1.0 + ink: 4.4.1(@types/react@18.3.23)(bufferutil@4.0.9)(react@18.3.1)(utf-8-validate@5.0.10) + '@isaacs/cliui@8.0.2': dependencies: string-width: 5.1.2 @@ -9422,7 +9646,7 @@ snapshots: transitivePeerDependencies: - encoding - '@m0-foundation/solana-m-api-sdk@0.1.7': + '@m0-foundation/solana-m-api-sdk@0.1.9': dependencies: form-data: 4.0.2 formdata-node: 6.0.3 @@ -11034,13 +11258,13 @@ snapshots: '@solana/errors@2.0.0-rc.1(typescript@5.8.3)': dependencies: - chalk: 5.4.1 + chalk: 5.6.0 commander: 12.1.0 typescript: 5.8.3 '@solana/errors@2.1.1(typescript@5.8.3)': dependencies: - chalk: 5.4.1 + chalk: 5.6.0 commander: 13.1.0 typescript: 5.8.3 @@ -12725,7 +12949,6 @@ snapshots: '@types/node@22.15.3': dependencies: undici-types: 6.21.0 - optional: true '@types/node@22.7.5': dependencies: @@ -12735,6 +12958,8 @@ snapshots: dependencies: '@types/node': 22.13.17 + '@types/prop-types@15.7.15': {} + '@types/qs@6.9.8': {} '@types/range-parser@1.2.7': {} @@ -12743,6 +12968,11 @@ snapshots: dependencies: '@types/react': 19.1.8 + '@types/react@18.3.23': + dependencies: + '@types/prop-types': 15.7.15 + csstype: 3.1.3 + '@types/react@19.1.8': dependencies: csstype: 3.1.3 @@ -14664,6 +14894,8 @@ snapshots: dependencies: type-fest: 0.21.3 + ansi-escapes@6.2.1: {} + ansi-regex@5.0.1: {} ansi-regex@6.1.0: {} @@ -14731,6 +14963,8 @@ snapshots: atomic-sleep@1.0.0: {} + auto-bind@5.0.1: {} + available-typed-arrays@1.0.7: dependencies: possible-typed-array-names: 1.1.0 @@ -14934,6 +15168,17 @@ snapshots: dependencies: fill-range: 7.1.1 + broadcast-channel@3.7.0: + dependencies: + '@babel/runtime': 7.27.6 + detect-node: 2.1.0 + js-sha3: 0.8.0 + microseconds: 0.2.0 + nano-time: 1.0.0 + oblivious-set: 1.0.0 + rimraf: 3.0.2 + unload: 2.2.0 + brorand@1.1.0: {} browser-headers@0.4.1: {} @@ -15125,7 +15370,7 @@ snapshots: ansi-styles: 4.3.0 supports-color: 7.2.0 - chalk@5.4.1: {} + chalk@5.6.0: {} char-regex@1.0.2: {} @@ -15156,6 +15401,19 @@ snapshots: cjs-module-lexer@1.4.3: {} + cli-boxes@3.0.0: {} + + cli-cursor@4.0.0: + dependencies: + restore-cursor: 4.0.0 + + cli-spinners@3.2.0: {} + + cli-truncate@3.1.0: + dependencies: + slice-ansi: 5.0.0 + string-width: 5.1.2 + client-only@0.0.1: {} cliui@6.0.0: @@ -15182,6 +15440,10 @@ snapshots: co@4.6.0: {} + code-excerpt@4.0.0: + dependencies: + convert-to-spaces: 2.0.1 + collect-v8-coverage@1.0.2: {} color-convert@1.9.3: @@ -15244,6 +15506,8 @@ snapshots: convert-source-map@2.0.0: {} + convert-to-spaces@2.0.1: {} + cookie-es@1.2.2: {} cookie-signature@1.0.6: {} @@ -15468,6 +15732,8 @@ snapshots: detect-newline@3.1.0: {} + detect-node@2.1.0: {} + diff-sequences@29.6.3: {} diff@4.0.2: {} @@ -15944,6 +16210,10 @@ snapshots: fecha@4.2.3: {} + figures@6.1.0: + dependencies: + is-unicode-supported: 2.1.0 + file-entry-cache@8.0.0: dependencies: flat-cache: 4.0.1 @@ -16247,6 +16517,8 @@ snapshots: imurmurhash@0.1.4: {} + indent-string@5.0.0: {} + inflight@1.0.6: dependencies: once: 1.4.0 @@ -16254,6 +16526,40 @@ snapshots: inherits@2.0.4: {} + ink@4.4.1(@types/react@18.3.23)(bufferutil@4.0.9)(react@18.3.1)(utf-8-validate@5.0.10): + dependencies: + '@alcalzone/ansi-tokenize': 0.1.3 + ansi-escapes: 6.2.1 + auto-bind: 5.0.1 + chalk: 5.6.0 + cli-boxes: 3.0.0 + cli-cursor: 4.0.0 + cli-truncate: 3.1.0 + code-excerpt: 4.0.0 + indent-string: 5.0.0 + is-ci: 3.0.1 + is-lower-case: 2.0.2 + is-upper-case: 2.0.2 + lodash: 4.17.21 + patch-console: 2.0.0 + react: 18.3.1 + react-reconciler: 0.29.2(react@18.3.1) + scheduler: 0.23.2 + signal-exit: 3.0.7 + slice-ansi: 6.0.0 + stack-utils: 2.0.6 + string-width: 5.1.2 + type-fest: 0.12.0 + widest-line: 4.0.1 + wrap-ansi: 8.1.0 + ws: 8.18.2(bufferutil@4.0.9)(utf-8-validate@5.0.10) + yoga-wasm-web: 0.3.3 + optionalDependencies: + '@types/react': 18.3.23 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + int64-buffer@1.1.0: {} internmap@2.0.3: {} @@ -16290,6 +16596,10 @@ snapshots: is-callable@1.2.7: {} + is-ci@3.0.1: + dependencies: + ci-info: 3.9.0 + is-core-module@2.16.1: dependencies: hasown: 2.0.2 @@ -16298,6 +16608,8 @@ snapshots: is-fullwidth-code-point@3.0.0: {} + is-fullwidth-code-point@4.0.0: {} + is-generator-fn@2.1.0: {} is-generator-function@1.1.0: @@ -16311,6 +16623,10 @@ snapshots: dependencies: is-extglob: 2.1.1 + is-lower-case@2.0.2: + dependencies: + tslib: 2.8.1 + is-nan@1.3.2: dependencies: call-bind: 1.0.8 @@ -16337,6 +16653,12 @@ snapshots: dependencies: which-typed-array: 1.1.19 + is-unicode-supported@2.1.0: {} + + is-upper-case@2.0.2: + dependencies: + tslib: 2.8.1 + isarray@1.0.0: {} isarray@2.0.5: {} @@ -17057,6 +17379,11 @@ snapshots: map-obj@4.3.0: {} + match-sorter@6.3.4: + dependencies: + '@babel/runtime': 7.27.6 + remove-accents: 0.5.0 + math-intrinsics@1.1.0: {} md5.js@1.3.5: @@ -17084,6 +17411,8 @@ snapshots: braces: 3.0.3 picomatch: 2.3.1 + microseconds@0.2.0: {} + miller-rabin@4.0.1: dependencies: bn.js: 4.12.2 @@ -17157,6 +17486,10 @@ snapshots: nan@2.22.2: {} + nano-time@1.0.0: + dependencies: + big-integer: 1.6.36 + nanoid@3.3.11: {} natural-compare@1.4.0: {} @@ -17302,6 +17635,8 @@ snapshots: has-symbols: 1.1.0 object-keys: 1.1.1 + oblivious-set@1.0.0: {} + oblivious-set@1.4.0: {} ofetch@1.4.1: @@ -17469,6 +17804,8 @@ snapshots: parseurl@1.3.3: {} + patch-console@2.0.0: {} + path-browserify@1.0.1: {} path-exists@4.0.0: {} @@ -17772,6 +18109,19 @@ snapshots: react-dom: 19.1.0(react@19.1.0) webrtc-adapter: 7.7.1 + react-query@3.39.3(react@18.3.1): + dependencies: + '@babel/runtime': 7.27.6 + broadcast-channel: 3.7.0 + match-sorter: 6.3.4 + react: 18.3.1 + + react-reconciler@0.29.2(react@18.3.1): + dependencies: + loose-envify: 1.4.0 + react: 18.3.1 + scheduler: 0.23.2 + react-router-dom@7.6.2(react-dom@19.1.0(react@19.1.0))(react@19.1.0): dependencies: react: 19.1.0 @@ -17809,6 +18159,10 @@ snapshots: react: 19.1.0 react-dom: 19.1.0(react@19.1.0) + react@18.3.1: + dependencies: + loose-envify: 1.4.0 + react@19.1.0: {} readable-stream@2.3.8: @@ -17871,6 +18225,8 @@ snapshots: '@types/react': 19.1.8 react: 19.1.0 + remove-accents@0.5.0: {} + require-addon@1.1.0: dependencies: bare-addon-resolve: 1.9.4(bare-url@2.1.6) @@ -17903,8 +18259,17 @@ snapshots: dependencies: lowercase-keys: 2.0.0 + restore-cursor@4.0.0: + dependencies: + onetime: 5.1.2 + signal-exit: 3.0.7 + reusify@1.1.0: {} + rimraf@3.0.2: + dependencies: + glob: 7.2.3 + ripemd160@2.0.2: dependencies: hash-base: 3.0.5 @@ -18024,6 +18389,10 @@ snapshots: '@solana/web3.js': 1.98.2(bufferutil@4.0.9)(typescript@5.8.3)(utf-8-validate@5.0.10) eventemitter3: 4.0.7 + scheduler@0.23.2: + dependencies: + loose-envify: 1.4.0 + scheduler@0.26.0: {} scrypt-js@3.0.1: {} @@ -18185,6 +18554,16 @@ snapshots: slash@3.0.0: {} + slice-ansi@5.0.0: + dependencies: + ansi-styles: 6.2.1 + is-fullwidth-code-point: 4.0.0 + + slice-ansi@6.0.0: + dependencies: + ansi-styles: 6.2.1 + is-fullwidth-code-point: 4.0.0 + smart-buffer@4.2.0: {} snake-case@3.0.4: @@ -18523,6 +18902,26 @@ snapshots: optionalDependencies: '@swc/core': 1.12.3(@swc/helpers@0.5.17) + ts-node@10.9.2(@swc/core@1.12.3(@swc/helpers@0.5.17))(@types/node@22.15.3)(typescript@5.8.3): + dependencies: + '@cspotcode/source-map-support': 0.8.1 + '@tsconfig/node10': 1.0.11 + '@tsconfig/node12': 1.0.11 + '@tsconfig/node14': 1.0.3 + '@tsconfig/node16': 1.0.4 + '@types/node': 22.15.3 + acorn: 8.14.1 + acorn-walk: 8.3.4 + arg: 4.1.3 + create-require: 1.1.1 + diff: 4.0.2 + make-error: 1.3.6 + typescript: 5.8.3 + v8-compile-cache-lib: 3.0.1 + yn: 3.1.1 + optionalDependencies: + '@swc/core': 1.12.3(@swc/helpers@0.5.17) + tslib@1.14.1: {} tslib@2.7.0: {} @@ -18567,6 +18966,8 @@ snapshots: type-detect@4.0.8: {} + type-fest@0.12.0: {} + type-fest@0.21.3: {} type-fest@3.13.1: {} @@ -18622,8 +19023,7 @@ snapshots: undici-types@6.20.0: {} - undici-types@6.21.0: - optional: true + undici-types@6.21.0: {} undici-types@7.11.0: {} @@ -18631,6 +19031,11 @@ snapshots: dependencies: ev-emitter: 2.1.2 + unload@2.2.0: + dependencies: + '@babel/runtime': 7.27.6 + detect-node: 2.1.0 + unload@2.4.1: {} unpipe@1.0.0: {} @@ -19182,6 +19587,10 @@ snapshots: dependencies: isexe: 2.0.0 + widest-line@4.0.1: + dependencies: + string-width: 5.1.2 + wif@5.0.0: dependencies: bs58check: 4.0.0 @@ -19337,6 +19746,8 @@ snapshots: yocto-queue@0.1.0: {} + yoga-wasm-web@0.3.3: {} + zen-observable-ts@1.2.5: dependencies: zen-observable: 0.8.15 diff --git a/services/api/fern/definition/swap.yml b/services/api/fern/definition/transactions.yml similarity index 56% rename from services/api/fern/definition/swap.yml rename to services/api/fern/definition/transactions.yml index e20bc708..057850a2 100644 --- a/services/api/fern/definition/swap.yml +++ b/services/api/fern/definition/transactions.yml @@ -2,7 +2,7 @@ service: auth: false - base-path: /swap + base-path: /transactions endpoints: quote: docs: Get swap quote @@ -19,6 +19,7 @@ service: outputMint: string amount: string slippageBps: optional + maxAccounts: optional examples: - query-parameters: inputMint: So11111111111111111111111111111111111111112 @@ -48,8 +49,8 @@ service: swap: docs: Get swap transaction method: GET - path: /transaction - response: Swap + path: /swap + response: Transaction errors: - QuoteNotFound - SimulationFailed @@ -64,8 +65,57 @@ service: userPublicKey: 'D76ySoHPwD8U2nnTTDqXeUJQg5UkD9UD1PUE1rnvPAGm' response: body: - simulationLogs: [] transaction: 'AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAQAGDkS+3LuGTbs......+/oD9qb31dH6i0QZ2IHELXUX3Y1YeW79p9Stkqk12z4yvZFJiQ4GCQwLBwYQBgUEDggNTQ==' + simulationLogs: + - Transaction successful + luts: + - 9JLRqBqkznKiSoNfotA4ywSRdnWb2fE76SiFrAfkaRCD + instructions: + - programId: 9JLRqBqkznKiSoNfotA4ywSRdnWb2fE76SiFrAfkaRCD + data: 3Bxs6mXg8fV7jXg5c6kUeXoGx5r4 + keys: + - pubkey: 9JLRqBqkznKiSoNfotA4ywSRdnWb2fE76SiFrAfkaRCD + isSigner: false + isWritable: true + + bridge: + docs: Get bridge transaction + method: GET + path: /bridge + response: Transaction + errors: + - BadBridgeRequest + - SimulationFailed + request: + name: GetBridgeRequest + query-parameters: + userPublicKey: string + fromChain: string + toChain: string + amount: string + recipientAddress: string + outboxItem: optional + examples: + - query-parameters: + fromChain: 'Ethereum' + toChain: 'Solana' + amount: '1000000' + userPublicKey: 'D76ySoHPwD8U2nnTTDqXeUJQg5UkD9UD1PUE1rnvPAGm' + recipientAddress: '0x77BAB32F75996de8075eBA62aEa7b1205cf7E004' + response: + body: + transaction: 'AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAQAGDkS+3LuGTbs......+/oD9qb31dH6i0QZ2IHELXUX3Y1YeW79p9Stkqk12z4yvZFJiQ4GCQwLBwYQBgUEDggNTQ==' + simulationLogs: + - Transaction successful + luts: + - 9JLRqBqkznKiSoNfotA4ywSRdnWb2fE76SiFrAfkaRCD + instructions: + - programId: 9JLRqBqkznKiSoNfotA4ywSRdnWb2fE76SiFrAfkaRCD + data: 3Bxs6mXg8fV7jXg5c6kUeXoGx5r4 + keys: + - pubkey: 9JLRqBqkznKiSoNfotA4ywSRdnWb2fE76SiFrAfkaRCD + isSigner: false + isWritable: true types: Quote: @@ -95,11 +145,29 @@ types: feeAmount: string feeMint: string - Swap: + Transaction: properties: transaction: string + instructions: list + luts: list simulationLogs: list + Instruction: + properties: + programId: string + data: string + keys: list + + AccountMeta: + properties: + pubkey: string + isSigner: boolean + isWritable: boolean + + ErrorWithMessage: + properties: + message: string + SwapRequestError: properties: message: string @@ -119,6 +187,10 @@ errors: status-code: 400 type: SwapRequestError - SimulationFailed: + BadBridgeRequest: status-code: 400 + type: ErrorWithMessage + + SimulationFailed: + status-code: 500 type: SwapRequestError diff --git a/services/api/sdk-go/client/client.go b/services/api/sdk-go/client/client.go index f5767c3e..9e72d285 100644 --- a/services/api/sdk-go/client/client.go +++ b/services/api/sdk-go/client/client.go @@ -8,8 +8,8 @@ import ( extensions "github.com/m0-foundation/solana-m/services/api/sdk-go/extensions" internal "github.com/m0-foundation/solana-m/services/api/sdk-go/internal" option "github.com/m0-foundation/solana-m/services/api/sdk-go/option" - swap "github.com/m0-foundation/solana-m/services/api/sdk-go/swap" tokenaccount "github.com/m0-foundation/solana-m/services/api/sdk-go/tokenaccount" + transactions "github.com/m0-foundation/solana-m/services/api/sdk-go/transactions" http "net/http" ) @@ -20,8 +20,8 @@ type Client struct { Events *events.Client Extensions *extensions.Client - Swap *swap.Client TokenAccount *tokenaccount.Client + Transactions *transactions.Client } func NewClient(opts ...option.RequestOption) *Client { @@ -37,7 +37,7 @@ func NewClient(opts ...option.RequestOption) *Client { header: options.ToHeader(), Events: events.NewClient(opts...), Extensions: extensions.NewClient(opts...), - Swap: swap.NewClient(opts...), TokenAccount: tokenaccount.NewClient(opts...), + Transactions: transactions.NewClient(opts...), } } diff --git a/services/api/sdk-go/errors.go b/services/api/sdk-go/errors.go index fdce9fd3..a5406b33 100644 --- a/services/api/sdk-go/errors.go +++ b/services/api/sdk-go/errors.go @@ -7,6 +7,52 @@ import ( core "github.com/m0-foundation/solana-m/services/api/sdk-go/core" ) +type InvalidMint struct { + *core.APIError + Body *RequestError +} + +func (i *InvalidMint) UnmarshalJSON(data []byte) error { + var body *RequestError + if err := json.Unmarshal(data, &body); err != nil { + return err + } + i.StatusCode = 404 + i.Body = body + return nil +} + +func (i *InvalidMint) MarshalJSON() ([]byte, error) { + return json.Marshal(i.Body) +} + +func (i *InvalidMint) Unwrap() error { + return i.APIError +} + +type BadBridgeRequest struct { + *core.APIError + Body *ErrorWithMessage +} + +func (b *BadBridgeRequest) UnmarshalJSON(data []byte) error { + var body *ErrorWithMessage + if err := json.Unmarshal(data, &body); err != nil { + return err + } + b.StatusCode = 400 + b.Body = body + return nil +} + +func (b *BadBridgeRequest) MarshalJSON() ([]byte, error) { + return json.Marshal(b.Body) +} + +func (b *BadBridgeRequest) Unwrap() error { + return b.APIError +} + type BadQuoteRequest struct { *core.APIError Body *SwapRequestError @@ -86,7 +132,7 @@ func (s *SimulationFailed) UnmarshalJSON(data []byte) error { if err := json.Unmarshal(data, &body); err != nil { return err } - s.StatusCode = 400 + s.StatusCode = 500 s.Body = body return nil } @@ -98,26 +144,3 @@ func (s *SimulationFailed) MarshalJSON() ([]byte, error) { func (s *SimulationFailed) Unwrap() error { return s.APIError } - -type InvalidMint struct { - *core.APIError - Body *RequestError -} - -func (i *InvalidMint) UnmarshalJSON(data []byte) error { - var body *RequestError - if err := json.Unmarshal(data, &body); err != nil { - return err - } - i.StatusCode = 404 - i.Body = body - return nil -} - -func (i *InvalidMint) MarshalJSON() ([]byte, error) { - return json.Marshal(i.Body) -} - -func (i *InvalidMint) Unwrap() error { - return i.APIError -} diff --git a/services/api/sdk-go/swap.go b/services/api/sdk-go/transactions.go similarity index 58% rename from services/api/sdk-go/swap.go rename to services/api/sdk-go/transactions.go index 4b9f631b..36636a01 100644 --- a/services/api/sdk-go/swap.go +++ b/services/api/sdk-go/transactions.go @@ -8,11 +8,21 @@ import ( internal "github.com/m0-foundation/solana-m/services/api/sdk-go/internal" ) +type GetBridgeRequest struct { + UserPublicKey string `json:"-" url:"userPublicKey"` + FromChain string `json:"-" url:"fromChain"` + ToChain string `json:"-" url:"toChain"` + Amount string `json:"-" url:"amount"` + RecipientAddress string `json:"-" url:"recipientAddress"` + OutboxItem *string `json:"-" url:"outboxItem,omitempty"` +} + type GetQuoteRequest struct { InputMint string `json:"-" url:"inputMint"` OutputMint string `json:"-" url:"outputMint"` Amount string `json:"-" url:"amount"` SlippageBps *int `json:"-" url:"slippageBps,omitempty"` + MaxAccounts *int `json:"-" url:"maxAccounts,omitempty"` } type GetSwapRequest struct { @@ -20,6 +30,176 @@ type GetSwapRequest struct { UserPublicKey string `json:"-" url:"userPublicKey"` } +type AccountMeta struct { + Pubkey string `json:"pubkey" url:"pubkey"` + IsSigner bool `json:"isSigner" url:"isSigner"` + IsWritable bool `json:"isWritable" url:"isWritable"` + + extraProperties map[string]interface{} + rawJSON json.RawMessage +} + +func (a *AccountMeta) GetPubkey() string { + if a == nil { + return "" + } + return a.Pubkey +} + +func (a *AccountMeta) GetIsSigner() bool { + if a == nil { + return false + } + return a.IsSigner +} + +func (a *AccountMeta) GetIsWritable() bool { + if a == nil { + return false + } + return a.IsWritable +} + +func (a *AccountMeta) GetExtraProperties() map[string]interface{} { + return a.extraProperties +} + +func (a *AccountMeta) UnmarshalJSON(data []byte) error { + type unmarshaler AccountMeta + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *a = AccountMeta(value) + extraProperties, err := internal.ExtractExtraProperties(data, *a) + if err != nil { + return err + } + a.extraProperties = extraProperties + a.rawJSON = json.RawMessage(data) + return nil +} + +func (a *AccountMeta) String() string { + if len(a.rawJSON) > 0 { + if value, err := internal.StringifyJSON(a.rawJSON); err == nil { + return value + } + } + if value, err := internal.StringifyJSON(a); err == nil { + return value + } + return fmt.Sprintf("%#v", a) +} + +type ErrorWithMessage struct { + Message string `json:"message" url:"message"` + + extraProperties map[string]interface{} + rawJSON json.RawMessage +} + +func (e *ErrorWithMessage) GetMessage() string { + if e == nil { + return "" + } + return e.Message +} + +func (e *ErrorWithMessage) GetExtraProperties() map[string]interface{} { + return e.extraProperties +} + +func (e *ErrorWithMessage) UnmarshalJSON(data []byte) error { + type unmarshaler ErrorWithMessage + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *e = ErrorWithMessage(value) + extraProperties, err := internal.ExtractExtraProperties(data, *e) + if err != nil { + return err + } + e.extraProperties = extraProperties + e.rawJSON = json.RawMessage(data) + return nil +} + +func (e *ErrorWithMessage) String() string { + if len(e.rawJSON) > 0 { + if value, err := internal.StringifyJSON(e.rawJSON); err == nil { + return value + } + } + if value, err := internal.StringifyJSON(e); err == nil { + return value + } + return fmt.Sprintf("%#v", e) +} + +type Instruction struct { + ProgramId string `json:"programId" url:"programId"` + Data string `json:"data" url:"data"` + Keys []*AccountMeta `json:"keys" url:"keys"` + + extraProperties map[string]interface{} + rawJSON json.RawMessage +} + +func (i *Instruction) GetProgramId() string { + if i == nil { + return "" + } + return i.ProgramId +} + +func (i *Instruction) GetData() string { + if i == nil { + return "" + } + return i.Data +} + +func (i *Instruction) GetKeys() []*AccountMeta { + if i == nil { + return nil + } + return i.Keys +} + +func (i *Instruction) GetExtraProperties() map[string]interface{} { + return i.extraProperties +} + +func (i *Instruction) UnmarshalJSON(data []byte) error { + type unmarshaler Instruction + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *i = Instruction(value) + extraProperties, err := internal.ExtractExtraProperties(data, *i) + if err != nil { + return err + } + i.extraProperties = extraProperties + i.rawJSON = json.RawMessage(data) + return nil +} + +func (i *Instruction) String() string { + if len(i.rawJSON) > 0 { + if value, err := internal.StringifyJSON(i.rawJSON); err == nil { + return value + } + } + if value, err := internal.StringifyJSON(i); err == nil { + return value + } + return fmt.Sprintf("%#v", i) +} + type Quote struct { QuoteId string `json:"quoteId" url:"quoteId"` InputMint string `json:"inputMint" url:"inputMint"` @@ -176,60 +356,6 @@ func (r *RoutePlan) String() string { return fmt.Sprintf("%#v", r) } -type Swap struct { - Transaction string `json:"transaction" url:"transaction"` - SimulationLogs []string `json:"simulationLogs" url:"simulationLogs"` - - extraProperties map[string]interface{} - rawJSON json.RawMessage -} - -func (s *Swap) GetTransaction() string { - if s == nil { - return "" - } - return s.Transaction -} - -func (s *Swap) GetSimulationLogs() []string { - if s == nil { - return nil - } - return s.SimulationLogs -} - -func (s *Swap) GetExtraProperties() map[string]interface{} { - return s.extraProperties -} - -func (s *Swap) UnmarshalJSON(data []byte) error { - type unmarshaler Swap - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *s = Swap(value) - extraProperties, err := internal.ExtractExtraProperties(data, *s) - if err != nil { - return err - } - s.extraProperties = extraProperties - s.rawJSON = json.RawMessage(data) - return nil -} - -func (s *Swap) String() string { - if len(s.rawJSON) > 0 { - if value, err := internal.StringifyJSON(s.rawJSON); err == nil { - return value - } - } - if value, err := internal.StringifyJSON(s); err == nil { - return value - } - return fmt.Sprintf("%#v", s) -} - type SwapInfo struct { AmmKey string `json:"ammKey" url:"ammKey"` Label string `json:"label" url:"label"` @@ -393,3 +519,73 @@ func (s *SwapRequestError) String() string { } return fmt.Sprintf("%#v", s) } + +type Transaction struct { + Transaction string `json:"transaction" url:"transaction"` + Instructions []*Instruction `json:"instructions" url:"instructions"` + Luts []string `json:"luts" url:"luts"` + SimulationLogs []string `json:"simulationLogs" url:"simulationLogs"` + + extraProperties map[string]interface{} + rawJSON json.RawMessage +} + +func (t *Transaction) GetTransaction() string { + if t == nil { + return "" + } + return t.Transaction +} + +func (t *Transaction) GetInstructions() []*Instruction { + if t == nil { + return nil + } + return t.Instructions +} + +func (t *Transaction) GetLuts() []string { + if t == nil { + return nil + } + return t.Luts +} + +func (t *Transaction) GetSimulationLogs() []string { + if t == nil { + return nil + } + return t.SimulationLogs +} + +func (t *Transaction) GetExtraProperties() map[string]interface{} { + return t.extraProperties +} + +func (t *Transaction) UnmarshalJSON(data []byte) error { + type unmarshaler Transaction + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *t = Transaction(value) + extraProperties, err := internal.ExtractExtraProperties(data, *t) + if err != nil { + return err + } + t.extraProperties = extraProperties + t.rawJSON = json.RawMessage(data) + return nil +} + +func (t *Transaction) String() string { + if len(t.rawJSON) > 0 { + if value, err := internal.StringifyJSON(t.rawJSON); err == nil { + return value + } + } + if value, err := internal.StringifyJSON(t); err == nil { + return value + } + return fmt.Sprintf("%#v", t) +} diff --git a/services/api/sdk-go/swap/client.go b/services/api/sdk-go/transactions/client.go similarity index 68% rename from services/api/sdk-go/swap/client.go rename to services/api/sdk-go/transactions/client.go index b4ac2fa9..be528144 100644 --- a/services/api/sdk-go/swap/client.go +++ b/services/api/sdk-go/transactions/client.go @@ -1,6 +1,6 @@ // Code generated by Fern. DO NOT EDIT. -package swap +package transactions import ( context "context" @@ -43,7 +43,7 @@ func (c *Client) Quote( c.baseURL, "https://api-production-0046.up.railway.app", ) - endpointURL := baseURL + "/swap/quote" + endpointURL := baseURL + "/transactions/quote" queryParams, err := internal.QueryValues(request) if err != nil { return nil, err @@ -93,14 +93,14 @@ func (c *Client) Swap( ctx context.Context, request *sdkgo.GetSwapRequest, opts ...option.RequestOption, -) (*sdkgo.Swap, error) { +) (*sdkgo.Transaction, error) { options := core.NewRequestOptions(opts...) baseURL := internal.ResolveBaseURL( options.BaseURL, c.baseURL, "https://api-production-0046.up.railway.app", ) - endpointURL := baseURL + "/swap/transaction" + endpointURL := baseURL + "/transactions/swap" queryParams, err := internal.QueryValues(request) if err != nil { return nil, err @@ -118,14 +118,71 @@ func (c *Client) Swap( APIError: apiError, } }, + 500: func(apiError *core.APIError) error { + return &sdkgo.SimulationFailed{ + APIError: apiError, + } + }, + } + + var response *sdkgo.Transaction + if err := c.caller.Call( + ctx, + &internal.CallParams{ + URL: endpointURL, + Method: http.MethodGet, + Headers: headers, + MaxAttempts: options.MaxAttempts, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Response: &response, + ErrorDecoder: internal.NewErrorDecoder(errorCodes), + }, + ); err != nil { + return nil, err + } + return response, nil +} + +// Get bridge transaction +func (c *Client) Bridge( + ctx context.Context, + request *sdkgo.GetBridgeRequest, + opts ...option.RequestOption, +) (*sdkgo.Transaction, error) { + options := core.NewRequestOptions(opts...) + baseURL := internal.ResolveBaseURL( + options.BaseURL, + c.baseURL, + "https://api-production-0046.up.railway.app", + ) + endpointURL := baseURL + "/transactions/bridge" + queryParams, err := internal.QueryValues(request) + if err != nil { + return nil, err + } + if len(queryParams) > 0 { + endpointURL += "?" + queryParams.Encode() + } + headers := internal.MergeHeaders( + c.header.Clone(), + options.ToHeader(), + ) + errorCodes := internal.ErrorCodes{ 400: func(apiError *core.APIError) error { + return &sdkgo.BadBridgeRequest{ + APIError: apiError, + } + }, + 500: func(apiError *core.APIError) error { return &sdkgo.SimulationFailed{ APIError: apiError, } }, } - var response *sdkgo.Swap + var response *sdkgo.Transaction if err := c.caller.Call( ctx, &internal.CallParams{ diff --git a/services/api/sdk-ts/generated/Client.ts b/services/api/sdk-ts/generated/Client.ts index 2c7ad38e..a97ee970 100644 --- a/services/api/sdk-ts/generated/Client.ts +++ b/services/api/sdk-ts/generated/Client.ts @@ -6,8 +6,8 @@ import * as environments from "./environments"; import * as core from "./core"; import { Events } from "./api/resources/events/client/Client"; import { Extensions } from "./api/resources/extensions/client/Client"; -import { Swap } from "./api/resources/swap/client/Client"; import { TokenAccount } from "./api/resources/tokenAccount/client/Client"; +import { Transactions } from "./api/resources/transactions/client/Client"; export declare namespace M0SolanaApiClient { export interface Options { @@ -31,8 +31,8 @@ export declare namespace M0SolanaApiClient { export class M0SolanaApiClient { protected _events: Events | undefined; protected _extensions: Extensions | undefined; - protected _swap: Swap | undefined; protected _tokenAccount: TokenAccount | undefined; + protected _transactions: Transactions | undefined; constructor(protected readonly _options: M0SolanaApiClient.Options = {}) {} @@ -44,11 +44,11 @@ export class M0SolanaApiClient { return (this._extensions ??= new Extensions(this._options)); } - public get swap(): Swap { - return (this._swap ??= new Swap(this._options)); - } - public get tokenAccount(): TokenAccount { return (this._tokenAccount ??= new TokenAccount(this._options)); } + + public get transactions(): Transactions { + return (this._transactions ??= new Transactions(this._options)); + } } diff --git a/services/api/sdk-ts/generated/api/resources/index.ts b/services/api/sdk-ts/generated/api/resources/index.ts index c638f9ad..6056b0fc 100644 --- a/services/api/sdk-ts/generated/api/resources/index.ts +++ b/services/api/sdk-ts/generated/api/resources/index.ts @@ -2,12 +2,12 @@ export * as events from "./events"; export * from "./events/types"; export * as extensions from "./extensions"; export * from "./extensions/types"; -export * as swap from "./swap"; -export * from "./swap/types"; export * as tokenAccount from "./tokenAccount"; export * from "./tokenAccount/types"; -export * from "./swap/errors"; +export * as transactions from "./transactions"; +export * from "./transactions/types"; export * from "./tokenAccount/errors"; +export * from "./transactions/errors"; export * from "./events/client/requests"; -export * from "./swap/client/requests"; export * from "./tokenAccount/client/requests"; +export * from "./transactions/client/requests"; diff --git a/services/api/sdk-ts/generated/api/resources/swap/types/Swap.ts b/services/api/sdk-ts/generated/api/resources/swap/types/Swap.ts deleted file mode 100644 index 49aaad66..00000000 --- a/services/api/sdk-ts/generated/api/resources/swap/types/Swap.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -export interface Swap { - transaction: string; - simulationLogs: string[]; -} diff --git a/services/api/sdk-ts/generated/api/resources/swap/types/index.ts b/services/api/sdk-ts/generated/api/resources/swap/types/index.ts deleted file mode 100644 index 3d292e60..00000000 --- a/services/api/sdk-ts/generated/api/resources/swap/types/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from "./Quote"; -export * from "./RoutePlan"; -export * from "./SwapInfo"; -export * from "./Swap"; -export * from "./SwapRequestError"; diff --git a/services/api/sdk-ts/generated/api/resources/swap/client/Client.ts b/services/api/sdk-ts/generated/api/resources/transactions/client/Client.ts similarity index 60% rename from services/api/sdk-ts/generated/api/resources/swap/client/Client.ts rename to services/api/sdk-ts/generated/api/resources/transactions/client/Client.ts index 72a44c4a..4d4f9c5d 100644 --- a/services/api/sdk-ts/generated/api/resources/swap/client/Client.ts +++ b/services/api/sdk-ts/generated/api/resources/transactions/client/Client.ts @@ -9,7 +9,7 @@ import urlJoin from "url-join"; import * as serializers from "../../../../serialization/index"; import * as errors from "../../../../errors/index"; -export declare namespace Swap { +export declare namespace Transactions { export interface Options { environment?: core.Supplier; /** Specify a custom URL to connect the client to. */ @@ -28,20 +28,20 @@ export declare namespace Swap { } } -export class Swap { - constructor(protected readonly _options: Swap.Options = {}) {} +export class Transactions { + constructor(protected readonly _options: Transactions.Options = {}) {} /** * Get swap quote * * @param {M0SolanaApi.GetQuoteRequest} request - * @param {Swap.RequestOptions} requestOptions - Request-specific configuration. + * @param {Transactions.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link M0SolanaApi.QuoteError} * @throws {@link M0SolanaApi.BadQuoteRequest} * * @example - * await client.swap.quote({ + * await client.transactions.quote({ * inputMint: "So11111111111111111111111111111111111111112", * outputMint: "usdkyPPxgV7sfNyKb8eDz66ogPrkRXG3wS2FVb6LLUf", * amount: "1000000" @@ -49,16 +49,16 @@ export class Swap { */ public quote( request: M0SolanaApi.GetQuoteRequest, - requestOptions?: Swap.RequestOptions, + requestOptions?: Transactions.RequestOptions, ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__quote(request, requestOptions)); } private async __quote( request: M0SolanaApi.GetQuoteRequest, - requestOptions?: Swap.RequestOptions, + requestOptions?: Transactions.RequestOptions, ): Promise> { - const { inputMint, outputMint, amount, slippageBps } = request; + const { inputMint, outputMint, amount, slippageBps, maxAccounts } = request; const _queryParams: Record = {}; _queryParams["inputMint"] = inputMint; _queryParams["outputMint"] = outputMint; @@ -67,12 +67,16 @@ export class Swap { _queryParams["slippageBps"] = slippageBps.toString(); } + if (maxAccounts != null) { + _queryParams["maxAccounts"] = maxAccounts.toString(); + } + const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.M0SolanaApiEnvironment.Mainnet, - "/swap/quote", + "/transactions/quote", ), method: "GET", headers: { @@ -139,7 +143,7 @@ export class Swap { rawResponse: _response.rawResponse, }); case "timeout": - throw new errors.M0SolanaApiTimeoutError("Timeout exceeded when calling GET /swap/quote."); + throw new errors.M0SolanaApiTimeoutError("Timeout exceeded when calling GET /transactions/quote."); case "unknown": throw new errors.M0SolanaApiError({ message: _response.error.errorMessage, @@ -152,28 +156,28 @@ export class Swap { * Get swap transaction * * @param {M0SolanaApi.GetSwapRequest} request - * @param {Swap.RequestOptions} requestOptions - Request-specific configuration. + * @param {Transactions.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link M0SolanaApi.QuoteNotFound} * @throws {@link M0SolanaApi.SimulationFailed} * * @example - * await client.swap.swap({ + * await client.transactions.swap({ * quoteId: "abc1234356", * userPublicKey: "D76ySoHPwD8U2nnTTDqXeUJQg5UkD9UD1PUE1rnvPAGm" * }) */ public swap( request: M0SolanaApi.GetSwapRequest, - requestOptions?: Swap.RequestOptions, - ): core.HttpResponsePromise { + requestOptions?: Transactions.RequestOptions, + ): core.HttpResponsePromise { return core.HttpResponsePromise.fromPromise(this.__swap(request, requestOptions)); } private async __swap( request: M0SolanaApi.GetSwapRequest, - requestOptions?: Swap.RequestOptions, - ): Promise> { + requestOptions?: Transactions.RequestOptions, + ): Promise> { const { quoteId, userPublicKey } = request; const _queryParams: Record = {}; _queryParams["quoteId"] = quoteId; @@ -183,7 +187,7 @@ export class Swap { (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.M0SolanaApiEnvironment.Mainnet, - "/swap/transaction", + "/transactions/swap", ), method: "GET", headers: { @@ -201,7 +205,7 @@ export class Swap { }); if (_response.ok) { return { - data: serializers.Swap.parseOrThrow(_response.body, { + data: serializers.Transaction.parseOrThrow(_response.body, { unrecognizedObjectKeys: "passthrough", allowUnrecognizedUnionMembers: true, allowUnrecognizedEnumValues: true, @@ -223,7 +227,128 @@ export class Swap { }), _response.rawResponse, ); + case 500: + throw new M0SolanaApi.SimulationFailed( + serializers.SwapRequestError.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], + }), + _response.rawResponse, + ); + default: + throw new errors.M0SolanaApiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.M0SolanaApiError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.M0SolanaApiTimeoutError("Timeout exceeded when calling GET /transactions/swap."); + case "unknown": + throw new errors.M0SolanaApiError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * Get bridge transaction + * + * @param {M0SolanaApi.GetBridgeRequest} request + * @param {Transactions.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link M0SolanaApi.BadBridgeRequest} + * @throws {@link M0SolanaApi.SimulationFailed} + * + * @example + * await client.transactions.bridge({ + * fromChain: "Ethereum", + * toChain: "Solana", + * amount: "1000000", + * userPublicKey: "D76ySoHPwD8U2nnTTDqXeUJQg5UkD9UD1PUE1rnvPAGm", + * recipientAddress: "0x77BAB32F75996de8075eBA62aEa7b1205cf7E004" + * }) + */ + public bridge( + request: M0SolanaApi.GetBridgeRequest, + requestOptions?: Transactions.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__bridge(request, requestOptions)); + } + + private async __bridge( + request: M0SolanaApi.GetBridgeRequest, + requestOptions?: Transactions.RequestOptions, + ): Promise> { + const { userPublicKey, fromChain, toChain, amount, recipientAddress, outboxItem } = request; + const _queryParams: Record = {}; + _queryParams["userPublicKey"] = userPublicKey; + _queryParams["fromChain"] = fromChain; + _queryParams["toChain"] = toChain; + _queryParams["amount"] = amount; + _queryParams["recipientAddress"] = recipientAddress; + if (outboxItem != null) { + _queryParams["outboxItem"] = outboxItem; + } + + const _response = await core.fetcher({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.M0SolanaApiEnvironment.Mainnet, + "/transactions/bridge", + ), + method: "GET", + headers: { + "X-Fern-Language": "JavaScript", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 30000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: serializers.Transaction.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], + }), + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { case 400: + throw new M0SolanaApi.BadBridgeRequest( + serializers.ErrorWithMessage.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], + }), + _response.rawResponse, + ); + case 500: throw new M0SolanaApi.SimulationFailed( serializers.SwapRequestError.parseOrThrow(_response.error.body, { unrecognizedObjectKeys: "passthrough", @@ -250,7 +375,7 @@ export class Swap { rawResponse: _response.rawResponse, }); case "timeout": - throw new errors.M0SolanaApiTimeoutError("Timeout exceeded when calling GET /swap/transaction."); + throw new errors.M0SolanaApiTimeoutError("Timeout exceeded when calling GET /transactions/bridge."); case "unknown": throw new errors.M0SolanaApiError({ message: _response.error.errorMessage, diff --git a/services/api/sdk-ts/generated/api/resources/swap/client/index.ts b/services/api/sdk-ts/generated/api/resources/transactions/client/index.ts similarity index 100% rename from services/api/sdk-ts/generated/api/resources/swap/client/index.ts rename to services/api/sdk-ts/generated/api/resources/transactions/client/index.ts diff --git a/services/api/sdk-ts/generated/api/resources/transactions/client/requests/GetBridgeRequest.ts b/services/api/sdk-ts/generated/api/resources/transactions/client/requests/GetBridgeRequest.ts new file mode 100644 index 00000000..7c3fac62 --- /dev/null +++ b/services/api/sdk-ts/generated/api/resources/transactions/client/requests/GetBridgeRequest.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * fromChain: "Ethereum", + * toChain: "Solana", + * amount: "1000000", + * userPublicKey: "D76ySoHPwD8U2nnTTDqXeUJQg5UkD9UD1PUE1rnvPAGm", + * recipientAddress: "0x77BAB32F75996de8075eBA62aEa7b1205cf7E004" + * } + */ +export interface GetBridgeRequest { + userPublicKey: string; + fromChain: string; + toChain: string; + amount: string; + recipientAddress: string; + outboxItem?: string; +} diff --git a/services/api/sdk-ts/generated/api/resources/swap/client/requests/GetQuoteRequest.ts b/services/api/sdk-ts/generated/api/resources/transactions/client/requests/GetQuoteRequest.ts similarity index 94% rename from services/api/sdk-ts/generated/api/resources/swap/client/requests/GetQuoteRequest.ts rename to services/api/sdk-ts/generated/api/resources/transactions/client/requests/GetQuoteRequest.ts index c66c5fce..98b18ef2 100644 --- a/services/api/sdk-ts/generated/api/resources/swap/client/requests/GetQuoteRequest.ts +++ b/services/api/sdk-ts/generated/api/resources/transactions/client/requests/GetQuoteRequest.ts @@ -15,4 +15,5 @@ export interface GetQuoteRequest { outputMint: string; amount: string; slippageBps?: number; + maxAccounts?: number; } diff --git a/services/api/sdk-ts/generated/api/resources/swap/client/requests/GetSwapRequest.ts b/services/api/sdk-ts/generated/api/resources/transactions/client/requests/GetSwapRequest.ts similarity index 100% rename from services/api/sdk-ts/generated/api/resources/swap/client/requests/GetSwapRequest.ts rename to services/api/sdk-ts/generated/api/resources/transactions/client/requests/GetSwapRequest.ts diff --git a/services/api/sdk-ts/generated/api/resources/swap/client/requests/index.ts b/services/api/sdk-ts/generated/api/resources/transactions/client/requests/index.ts similarity index 65% rename from services/api/sdk-ts/generated/api/resources/swap/client/requests/index.ts rename to services/api/sdk-ts/generated/api/resources/transactions/client/requests/index.ts index f08502d8..7d392780 100644 --- a/services/api/sdk-ts/generated/api/resources/swap/client/requests/index.ts +++ b/services/api/sdk-ts/generated/api/resources/transactions/client/requests/index.ts @@ -1,2 +1,3 @@ export { type GetQuoteRequest } from "./GetQuoteRequest"; export { type GetSwapRequest } from "./GetSwapRequest"; +export { type GetBridgeRequest } from "./GetBridgeRequest"; diff --git a/services/api/sdk-ts/generated/api/resources/transactions/errors/BadBridgeRequest.ts b/services/api/sdk-ts/generated/api/resources/transactions/errors/BadBridgeRequest.ts new file mode 100644 index 00000000..6df063d5 --- /dev/null +++ b/services/api/sdk-ts/generated/api/resources/transactions/errors/BadBridgeRequest.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as errors from "../../../../errors/index"; +import * as M0SolanaApi from "../../../index"; +import * as core from "../../../../core"; + +export class BadBridgeRequest extends errors.M0SolanaApiError { + constructor(body: M0SolanaApi.ErrorWithMessage, rawResponse?: core.RawResponse) { + super({ + message: "BadBridgeRequest", + statusCode: 400, + body: body, + rawResponse: rawResponse, + }); + Object.setPrototypeOf(this, BadBridgeRequest.prototype); + } +} diff --git a/services/api/sdk-ts/generated/api/resources/swap/errors/BadQuoteRequest.ts b/services/api/sdk-ts/generated/api/resources/transactions/errors/BadQuoteRequest.ts similarity index 100% rename from services/api/sdk-ts/generated/api/resources/swap/errors/BadQuoteRequest.ts rename to services/api/sdk-ts/generated/api/resources/transactions/errors/BadQuoteRequest.ts diff --git a/services/api/sdk-ts/generated/api/resources/swap/errors/QuoteError.ts b/services/api/sdk-ts/generated/api/resources/transactions/errors/QuoteError.ts similarity index 100% rename from services/api/sdk-ts/generated/api/resources/swap/errors/QuoteError.ts rename to services/api/sdk-ts/generated/api/resources/transactions/errors/QuoteError.ts diff --git a/services/api/sdk-ts/generated/api/resources/swap/errors/QuoteNotFound.ts b/services/api/sdk-ts/generated/api/resources/transactions/errors/QuoteNotFound.ts similarity index 100% rename from services/api/sdk-ts/generated/api/resources/swap/errors/QuoteNotFound.ts rename to services/api/sdk-ts/generated/api/resources/transactions/errors/QuoteNotFound.ts diff --git a/services/api/sdk-ts/generated/api/resources/swap/errors/SimulationFailed.ts b/services/api/sdk-ts/generated/api/resources/transactions/errors/SimulationFailed.ts similarity index 95% rename from services/api/sdk-ts/generated/api/resources/swap/errors/SimulationFailed.ts rename to services/api/sdk-ts/generated/api/resources/transactions/errors/SimulationFailed.ts index 0b9f1605..a3f6b390 100644 --- a/services/api/sdk-ts/generated/api/resources/swap/errors/SimulationFailed.ts +++ b/services/api/sdk-ts/generated/api/resources/transactions/errors/SimulationFailed.ts @@ -10,7 +10,7 @@ export class SimulationFailed extends errors.M0SolanaApiError { constructor(body: M0SolanaApi.SwapRequestError, rawResponse?: core.RawResponse) { super({ message: "SimulationFailed", - statusCode: 400, + statusCode: 500, body: body, rawResponse: rawResponse, }); diff --git a/services/api/sdk-ts/generated/api/resources/swap/errors/index.ts b/services/api/sdk-ts/generated/api/resources/transactions/errors/index.ts similarity index 78% rename from services/api/sdk-ts/generated/api/resources/swap/errors/index.ts rename to services/api/sdk-ts/generated/api/resources/transactions/errors/index.ts index 97c7d587..78f1de8e 100644 --- a/services/api/sdk-ts/generated/api/resources/swap/errors/index.ts +++ b/services/api/sdk-ts/generated/api/resources/transactions/errors/index.ts @@ -1,4 +1,5 @@ export * from "./QuoteNotFound"; export * from "./QuoteError"; export * from "./BadQuoteRequest"; +export * from "./BadBridgeRequest"; export * from "./SimulationFailed"; diff --git a/services/api/sdk-ts/generated/api/resources/swap/index.ts b/services/api/sdk-ts/generated/api/resources/transactions/index.ts similarity index 100% rename from services/api/sdk-ts/generated/api/resources/swap/index.ts rename to services/api/sdk-ts/generated/api/resources/transactions/index.ts diff --git a/services/api/sdk-ts/generated/api/resources/transactions/types/AccountMeta.ts b/services/api/sdk-ts/generated/api/resources/transactions/types/AccountMeta.ts new file mode 100644 index 00000000..aeb117b4 --- /dev/null +++ b/services/api/sdk-ts/generated/api/resources/transactions/types/AccountMeta.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface AccountMeta { + pubkey: string; + isSigner: boolean; + isWritable: boolean; +} diff --git a/services/api/sdk-ts/generated/api/resources/transactions/types/ErrorWithMessage.ts b/services/api/sdk-ts/generated/api/resources/transactions/types/ErrorWithMessage.ts new file mode 100644 index 00000000..a6d7d14a --- /dev/null +++ b/services/api/sdk-ts/generated/api/resources/transactions/types/ErrorWithMessage.ts @@ -0,0 +1,7 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface ErrorWithMessage { + message: string; +} diff --git a/services/api/sdk-ts/generated/api/resources/transactions/types/Instruction.ts b/services/api/sdk-ts/generated/api/resources/transactions/types/Instruction.ts new file mode 100644 index 00000000..e84d3222 --- /dev/null +++ b/services/api/sdk-ts/generated/api/resources/transactions/types/Instruction.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as M0SolanaApi from "../../../index"; + +export interface Instruction { + programId: string; + data: string; + keys: M0SolanaApi.AccountMeta[]; +} diff --git a/services/api/sdk-ts/generated/api/resources/swap/types/Quote.ts b/services/api/sdk-ts/generated/api/resources/transactions/types/Quote.ts similarity index 100% rename from services/api/sdk-ts/generated/api/resources/swap/types/Quote.ts rename to services/api/sdk-ts/generated/api/resources/transactions/types/Quote.ts diff --git a/services/api/sdk-ts/generated/api/resources/swap/types/RoutePlan.ts b/services/api/sdk-ts/generated/api/resources/transactions/types/RoutePlan.ts similarity index 100% rename from services/api/sdk-ts/generated/api/resources/swap/types/RoutePlan.ts rename to services/api/sdk-ts/generated/api/resources/transactions/types/RoutePlan.ts diff --git a/services/api/sdk-ts/generated/api/resources/swap/types/SwapInfo.ts b/services/api/sdk-ts/generated/api/resources/transactions/types/SwapInfo.ts similarity index 100% rename from services/api/sdk-ts/generated/api/resources/swap/types/SwapInfo.ts rename to services/api/sdk-ts/generated/api/resources/transactions/types/SwapInfo.ts diff --git a/services/api/sdk-ts/generated/api/resources/swap/types/SwapRequestError.ts b/services/api/sdk-ts/generated/api/resources/transactions/types/SwapRequestError.ts similarity index 100% rename from services/api/sdk-ts/generated/api/resources/swap/types/SwapRequestError.ts rename to services/api/sdk-ts/generated/api/resources/transactions/types/SwapRequestError.ts diff --git a/services/api/sdk-ts/generated/api/resources/transactions/types/Transaction.ts b/services/api/sdk-ts/generated/api/resources/transactions/types/Transaction.ts new file mode 100644 index 00000000..ed52bad1 --- /dev/null +++ b/services/api/sdk-ts/generated/api/resources/transactions/types/Transaction.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as M0SolanaApi from "../../../index"; + +export interface Transaction { + transaction: string; + instructions: M0SolanaApi.Instruction[]; + luts: string[]; + simulationLogs: string[]; +} diff --git a/services/api/sdk-ts/generated/api/resources/transactions/types/index.ts b/services/api/sdk-ts/generated/api/resources/transactions/types/index.ts new file mode 100644 index 00000000..7f3caf9f --- /dev/null +++ b/services/api/sdk-ts/generated/api/resources/transactions/types/index.ts @@ -0,0 +1,8 @@ +export * from "./Quote"; +export * from "./RoutePlan"; +export * from "./SwapInfo"; +export * from "./Transaction"; +export * from "./Instruction"; +export * from "./AccountMeta"; +export * from "./ErrorWithMessage"; +export * from "./SwapRequestError"; diff --git a/services/api/sdk-ts/generated/serialization/resources/index.ts b/services/api/sdk-ts/generated/serialization/resources/index.ts index e23005ad..36e4e06e 100644 --- a/services/api/sdk-ts/generated/serialization/resources/index.ts +++ b/services/api/sdk-ts/generated/serialization/resources/index.ts @@ -2,7 +2,7 @@ export * as events from "./events"; export * from "./events/types"; export * as extensions from "./extensions"; export * from "./extensions/types"; -export * as swap from "./swap"; -export * from "./swap/types"; export * as tokenAccount from "./tokenAccount"; export * from "./tokenAccount/types"; +export * as transactions from "./transactions"; +export * from "./transactions/types"; diff --git a/services/api/sdk-ts/generated/serialization/resources/swap/types/Swap.ts b/services/api/sdk-ts/generated/serialization/resources/swap/types/Swap.ts deleted file mode 100644 index da66e373..00000000 --- a/services/api/sdk-ts/generated/serialization/resources/swap/types/Swap.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from "../../../index"; -import * as M0SolanaApi from "../../../../api/index"; -import * as core from "../../../../core"; - -export const Swap: core.serialization.ObjectSchema = core.serialization.object({ - transaction: core.serialization.string(), - simulationLogs: core.serialization.list(core.serialization.string()), -}); - -export declare namespace Swap { - export interface Raw { - transaction: string; - simulationLogs: string[]; - } -} diff --git a/services/api/sdk-ts/generated/serialization/resources/swap/types/index.ts b/services/api/sdk-ts/generated/serialization/resources/swap/types/index.ts deleted file mode 100644 index 3d292e60..00000000 --- a/services/api/sdk-ts/generated/serialization/resources/swap/types/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from "./Quote"; -export * from "./RoutePlan"; -export * from "./SwapInfo"; -export * from "./Swap"; -export * from "./SwapRequestError"; diff --git a/services/api/sdk-ts/generated/serialization/resources/swap/index.ts b/services/api/sdk-ts/generated/serialization/resources/transactions/index.ts similarity index 100% rename from services/api/sdk-ts/generated/serialization/resources/swap/index.ts rename to services/api/sdk-ts/generated/serialization/resources/transactions/index.ts diff --git a/services/api/sdk-ts/generated/serialization/resources/transactions/types/AccountMeta.ts b/services/api/sdk-ts/generated/serialization/resources/transactions/types/AccountMeta.ts new file mode 100644 index 00000000..4da1f96a --- /dev/null +++ b/services/api/sdk-ts/generated/serialization/resources/transactions/types/AccountMeta.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../index"; +import * as M0SolanaApi from "../../../../api/index"; +import * as core from "../../../../core"; + +export const AccountMeta: core.serialization.ObjectSchema = + core.serialization.object({ + pubkey: core.serialization.string(), + isSigner: core.serialization.boolean(), + isWritable: core.serialization.boolean(), + }); + +export declare namespace AccountMeta { + export interface Raw { + pubkey: string; + isSigner: boolean; + isWritable: boolean; + } +} diff --git a/services/api/sdk-ts/generated/serialization/resources/transactions/types/ErrorWithMessage.ts b/services/api/sdk-ts/generated/serialization/resources/transactions/types/ErrorWithMessage.ts new file mode 100644 index 00000000..6e3e05c9 --- /dev/null +++ b/services/api/sdk-ts/generated/serialization/resources/transactions/types/ErrorWithMessage.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../index"; +import * as M0SolanaApi from "../../../../api/index"; +import * as core from "../../../../core"; + +export const ErrorWithMessage: core.serialization.ObjectSchema< + serializers.ErrorWithMessage.Raw, + M0SolanaApi.ErrorWithMessage +> = core.serialization.object({ + message: core.serialization.string(), +}); + +export declare namespace ErrorWithMessage { + export interface Raw { + message: string; + } +} diff --git a/services/api/sdk-ts/generated/serialization/resources/transactions/types/Instruction.ts b/services/api/sdk-ts/generated/serialization/resources/transactions/types/Instruction.ts new file mode 100644 index 00000000..8d6d4fd3 --- /dev/null +++ b/services/api/sdk-ts/generated/serialization/resources/transactions/types/Instruction.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../index"; +import * as M0SolanaApi from "../../../../api/index"; +import * as core from "../../../../core"; +import { AccountMeta } from "./AccountMeta"; + +export const Instruction: core.serialization.ObjectSchema = + core.serialization.object({ + programId: core.serialization.string(), + data: core.serialization.string(), + keys: core.serialization.list(AccountMeta), + }); + +export declare namespace Instruction { + export interface Raw { + programId: string; + data: string; + keys: AccountMeta.Raw[]; + } +} diff --git a/services/api/sdk-ts/generated/serialization/resources/swap/types/Quote.ts b/services/api/sdk-ts/generated/serialization/resources/transactions/types/Quote.ts similarity index 100% rename from services/api/sdk-ts/generated/serialization/resources/swap/types/Quote.ts rename to services/api/sdk-ts/generated/serialization/resources/transactions/types/Quote.ts diff --git a/services/api/sdk-ts/generated/serialization/resources/swap/types/RoutePlan.ts b/services/api/sdk-ts/generated/serialization/resources/transactions/types/RoutePlan.ts similarity index 100% rename from services/api/sdk-ts/generated/serialization/resources/swap/types/RoutePlan.ts rename to services/api/sdk-ts/generated/serialization/resources/transactions/types/RoutePlan.ts diff --git a/services/api/sdk-ts/generated/serialization/resources/swap/types/SwapInfo.ts b/services/api/sdk-ts/generated/serialization/resources/transactions/types/SwapInfo.ts similarity index 100% rename from services/api/sdk-ts/generated/serialization/resources/swap/types/SwapInfo.ts rename to services/api/sdk-ts/generated/serialization/resources/transactions/types/SwapInfo.ts diff --git a/services/api/sdk-ts/generated/serialization/resources/swap/types/SwapRequestError.ts b/services/api/sdk-ts/generated/serialization/resources/transactions/types/SwapRequestError.ts similarity index 100% rename from services/api/sdk-ts/generated/serialization/resources/swap/types/SwapRequestError.ts rename to services/api/sdk-ts/generated/serialization/resources/transactions/types/SwapRequestError.ts diff --git a/services/api/sdk-ts/generated/serialization/resources/transactions/types/Transaction.ts b/services/api/sdk-ts/generated/serialization/resources/transactions/types/Transaction.ts new file mode 100644 index 00000000..8db4014c --- /dev/null +++ b/services/api/sdk-ts/generated/serialization/resources/transactions/types/Transaction.ts @@ -0,0 +1,25 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../index"; +import * as M0SolanaApi from "../../../../api/index"; +import * as core from "../../../../core"; +import { Instruction } from "./Instruction"; + +export const Transaction: core.serialization.ObjectSchema = + core.serialization.object({ + transaction: core.serialization.string(), + instructions: core.serialization.list(Instruction), + luts: core.serialization.list(core.serialization.string()), + simulationLogs: core.serialization.list(core.serialization.string()), + }); + +export declare namespace Transaction { + export interface Raw { + transaction: string; + instructions: Instruction.Raw[]; + luts: string[]; + simulationLogs: string[]; + } +} diff --git a/services/api/sdk-ts/generated/serialization/resources/transactions/types/index.ts b/services/api/sdk-ts/generated/serialization/resources/transactions/types/index.ts new file mode 100644 index 00000000..7f3caf9f --- /dev/null +++ b/services/api/sdk-ts/generated/serialization/resources/transactions/types/index.ts @@ -0,0 +1,8 @@ +export * from "./Quote"; +export * from "./RoutePlan"; +export * from "./SwapInfo"; +export * from "./Transaction"; +export * from "./Instruction"; +export * from "./AccountMeta"; +export * from "./ErrorWithMessage"; +export * from "./SwapRequestError"; diff --git a/services/api/sdk-ts/package.json b/services/api/sdk-ts/package.json index 6a9d12a9..bc78869d 100644 --- a/services/api/sdk-ts/package.json +++ b/services/api/sdk-ts/package.json @@ -1,7 +1,7 @@ { "name": "@m0-foundation/solana-m-api-sdk", "description": "Solana M API SDK", - "version": "0.1.8", + "version": "0.1.10", "main": "./dist/index.js", "module": "./dist/index.mjs", "types": "./dist/index.d.ts", diff --git a/services/api/server/package.json b/services/api/server/package.json index 102049e9..907b16e1 100644 --- a/services/api/server/package.json +++ b/services/api/server/package.json @@ -19,7 +19,10 @@ "@jup-ag/api": "^6.0.44", "@solana-program/token-2022": "^0.4.2", "@solana/kit": "^2.1.1", + "@solana/spl-token": "catalog:", "@solana/web3.js": "catalog:", + "@wormhole-foundation/sdk": "catalog:", + "@wormhole-foundation/sdk-solana-ntt": "catalog:", "apicache": "^1.6.3", "cors": "^2.8.5", "express": "^4.21.2", diff --git a/services/api/server/src/programs/ext_swap.json b/services/api/server/src/programs/ext_swap.json index 2e705300..c61d5614 100644 --- a/services/api/server/src/programs/ext_swap.json +++ b/services/api/server/src/programs/ext_swap.json @@ -9,7 +9,16 @@ "instructions": [ { "name": "initialize_global", - "discriminator": [47, 225, 15, 112, 86, 51, 190, 231], + "discriminator": [ + 47, + 225, + 15, + 112, + 86, + 51, + 190, + 231 + ], "accounts": [ { "name": "admin", @@ -23,7 +32,14 @@ "seeds": [ { "kind": "const", - "value": [103, 108, 111, 98, 97, 108] + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] } ] } @@ -37,13 +53,24 @@ }, { "name": "remove_whitelisted_extension", - "discriminator": [248, 52, 115, 71, 67, 42, 71, 252], + "discriminator": [ + 248, + 52, + 115, + 71, + 67, + 42, + 71, + 252 + ], "accounts": [ { "name": "admin", "writable": true, "signer": true, - "relations": ["swap_global"] + "relations": [ + "swap_global" + ] }, { "name": "swap_global", @@ -52,7 +79,14 @@ "seeds": [ { "kind": "const", - "value": [103, 108, 111, 98, 97, 108] + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] } ] } @@ -67,13 +101,24 @@ }, { "name": "remove_whitelisted_unwrapper", - "discriminator": [166, 23, 120, 95, 66, 168, 192, 163], + "discriminator": [ + 166, + 23, + 120, + 95, + 66, + 168, + 192, + 163 + ], "accounts": [ { "name": "admin", "writable": true, "signer": true, - "relations": ["swap_global"] + "relations": [ + "swap_global" + ] }, { "name": "swap_global", @@ -82,7 +127,14 @@ "seeds": [ { "kind": "const", - "value": [103, 108, 111, 98, 97, 108] + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] } ] } @@ -97,7 +149,16 @@ }, { "name": "swap", - "discriminator": [248, 198, 158, 145, 225, 117, 135, 200], + "discriminator": [ + 248, + 198, + 158, + 145, + 225, + 117, + 135, + 200 + ], "accounts": [ { "name": "signer", @@ -120,7 +181,14 @@ "seeds": [ { "kind": "const", - "value": [103, 108, 111, 98, 97, 108] + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] } ] } @@ -132,7 +200,14 @@ "seeds": [ { "kind": "const", - "value": [103, 108, 111, 98, 97, 108] + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] } ], "program": { @@ -148,7 +223,14 @@ "seeds": [ { "kind": "const", - "value": [103, 108, 111, 98, 97, 108] + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] } ], "program": { @@ -163,26 +245,67 @@ "seeds": [ { "kind": "const", - "value": [103, 108, 111, 98, 97, 108] + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] } ], "program": { "kind": "const", "value": [ - 5, 96, 203, 194, 112, 168, 176, 78, 85, 26, 180, 224, 26, 229, 153, 66, 23, 208, 230, 56, 28, 164, 98, - 240, 154, 37, 49, 118, 130, 244, 142, 245 + 5, + 96, + 203, + 194, + 112, + 168, + 176, + 78, + 85, + 26, + 180, + 224, + 26, + 229, + 153, + 66, + 23, + 208, + 230, + 56, + 28, + 164, + 98, + 240, + 154, + 37, + 49, + 118, + 130, + 244, + 142, + 245 ] } } }, { "name": "from_mint", - "docs": ["Validated by unwrap on the extension program"], + "docs": [ + "Validated by unwrap on the extension program" + ], "writable": true }, { "name": "to_mint", - "docs": ["Validated by wrap on the extension program"], + "docs": [ + "Validated by wrap on the extension program" + ], "writable": true }, { @@ -213,8 +336,38 @@ "program": { "kind": "const", "value": [ - 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16, - 132, 4, 142, 123, 216, 219, 233, 248, 89 + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 ] } } @@ -240,8 +393,38 @@ "program": { "kind": "const", "value": [ - 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16, - 132, 4, 142, 123, 216, 219, 233, 248, 89 + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 ] } } @@ -252,7 +435,15 @@ "seeds": [ { "kind": "const", - "value": [109, 95, 118, 97, 117, 108, 116] + "value": [ + 109, + 95, + 118, + 97, + 117, + 108, + 116 + ] } ], "program": { @@ -267,7 +458,15 @@ "seeds": [ { "kind": "const", - "value": [109, 95, 118, 97, 117, 108, 116] + "value": [ + 109, + 95, + 118, + 97, + 117, + 108, + 116 + ] } ], "program": { @@ -282,7 +481,22 @@ "seeds": [ { "kind": "const", - "value": [109, 105, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121] + "value": [ + 109, + 105, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] } ], "program": { @@ -297,7 +511,22 @@ "seeds": [ { "kind": "const", - "value": [109, 105, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121] + "value": [ + 109, + 105, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] } ], "program": { @@ -333,8 +562,38 @@ "program": { "kind": "const", "value": [ - 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16, - 132, 4, 142, 123, 216, 219, 233, 248, 89 + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 ] } } @@ -360,8 +619,38 @@ "program": { "kind": "const", "value": [ - 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16, - 132, 4, 142, 123, 216, 219, 233, 248, 89 + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 ] } } @@ -403,7 +692,16 @@ }, { "name": "unwrap", - "discriminator": [126, 175, 198, 14, 212, 69, 50, 44], + "discriminator": [ + 126, + 175, + 198, + 14, + 212, + 69, + 50, + 44 + ], "accounts": [ { "name": "signer", @@ -421,7 +719,14 @@ "seeds": [ { "kind": "const", - "value": [103, 108, 111, 98, 97, 108] + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] } ] } @@ -433,7 +738,14 @@ "seeds": [ { "kind": "const", - "value": [103, 108, 111, 98, 97, 108] + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] } ], "program": { @@ -448,21 +760,60 @@ "seeds": [ { "kind": "const", - "value": [103, 108, 111, 98, 97, 108] + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] } ], "program": { "kind": "const", "value": [ - 5, 96, 203, 194, 112, 168, 176, 78, 85, 26, 180, 224, 26, 229, 153, 66, 23, 208, 230, 56, 28, 164, 98, - 240, 154, 37, 49, 118, 130, 244, 142, 245 + 5, + 96, + 203, + 194, + 112, + 168, + 176, + 78, + 85, + 26, + 180, + 224, + 26, + 229, + 153, + 66, + 23, + 208, + 230, + 56, + 28, + 164, + 98, + 240, + 154, + 37, + 49, + 118, + 130, + 244, + 142, + 245 ] } } }, { "name": "from_mint", - "docs": ["Validated by unwrap on the extension program"], + "docs": [ + "Validated by unwrap on the extension program" + ], "writable": true }, { @@ -489,8 +840,38 @@ "program": { "kind": "const", "value": [ - 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16, - 132, 4, 142, 123, 216, 219, 233, 248, 89 + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 ] } } @@ -516,8 +897,38 @@ "program": { "kind": "const", "value": [ - 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16, - 132, 4, 142, 123, 216, 219, 233, 248, 89 + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 ] } } @@ -528,7 +939,15 @@ "seeds": [ { "kind": "const", - "value": [109, 95, 118, 97, 117, 108, 116] + "value": [ + 109, + 95, + 118, + 97, + 117, + 108, + 116 + ] } ], "program": { @@ -543,7 +962,22 @@ "seeds": [ { "kind": "const", - "value": [109, 105, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121] + "value": [ + 109, + 105, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] } ], "program": { @@ -573,8 +1007,38 @@ "program": { "kind": "const", "value": [ - 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16, - 132, 4, 142, 123, 216, 219, 233, 248, 89 + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 ] } } @@ -609,13 +1073,24 @@ }, { "name": "whitelist_extension", - "discriminator": [186, 175, 23, 231, 77, 201, 205, 165], + "discriminator": [ + 186, + 175, + 23, + 231, + 77, + 201, + 205, + 165 + ], "accounts": [ { "name": "admin", "writable": true, "signer": true, - "relations": ["swap_global"] + "relations": [ + "swap_global" + ] }, { "name": "swap_global", @@ -624,7 +1099,14 @@ "seeds": [ { "kind": "const", - "value": [103, 108, 111, 98, 97, 108] + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] } ] } @@ -641,13 +1123,24 @@ }, { "name": "whitelist_unwrapper", - "discriminator": [219, 87, 23, 47, 189, 191, 123, 235], + "discriminator": [ + 219, + 87, + 23, + 47, + 189, + 191, + 123, + 235 + ], "accounts": [ { "name": "admin", "writable": true, "signer": true, - "relations": ["swap_global"] + "relations": [ + "swap_global" + ] }, { "name": "swap_global", @@ -656,7 +1149,14 @@ "seeds": [ { "kind": "const", - "value": [103, 108, 111, 98, 97, 108] + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] } ] } @@ -675,7 +1175,16 @@ }, { "name": "wrap", - "discriminator": [178, 40, 10, 189, 228, 129, 186, 140], + "discriminator": [ + 178, + 40, + 10, + 189, + 228, + 129, + 186, + 140 + ], "accounts": [ { "name": "signer", @@ -693,7 +1202,14 @@ "seeds": [ { "kind": "const", - "value": [103, 108, 111, 98, 97, 108] + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] } ] } @@ -705,7 +1221,14 @@ "seeds": [ { "kind": "const", - "value": [103, 108, 111, 98, 97, 108] + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] } ], "program": { @@ -720,21 +1243,60 @@ "seeds": [ { "kind": "const", - "value": [103, 108, 111, 98, 97, 108] + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] } ], "program": { "kind": "const", "value": [ - 5, 96, 203, 194, 112, 168, 176, 78, 85, 26, 180, 224, 26, 229, 153, 66, 23, 208, 230, 56, 28, 164, 98, - 240, 154, 37, 49, 118, 130, 244, 142, 245 + 5, + 96, + 203, + 194, + 112, + 168, + 176, + 78, + 85, + 26, + 180, + 224, + 26, + 229, + 153, + 66, + 23, + 208, + 230, + 56, + 28, + 164, + 98, + 240, + 154, + 37, + 49, + 118, + 130, + 244, + 142, + 245 ] } } }, { "name": "to_mint", - "docs": ["Validated by wrap on the extension program"], + "docs": [ + "Validated by wrap on the extension program" + ], "writable": true }, { @@ -761,8 +1323,38 @@ "program": { "kind": "const", "value": [ - 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16, - 132, 4, 142, 123, 216, 219, 233, 248, 89 + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 ] } } @@ -788,8 +1380,38 @@ "program": { "kind": "const", "value": [ - 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16, - 132, 4, 142, 123, 216, 219, 233, 248, 89 + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 ] } } @@ -800,7 +1422,15 @@ "seeds": [ { "kind": "const", - "value": [109, 95, 118, 97, 117, 108, 116] + "value": [ + 109, + 95, + 118, + 97, + 117, + 108, + 116 + ] } ], "program": { @@ -815,7 +1445,22 @@ "seeds": [ { "kind": "const", - "value": [109, 105, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121] + "value": [ + 109, + 105, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] } ], "program": { @@ -845,8 +1490,38 @@ "program": { "kind": "const", "value": [ - 140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16, - 132, 4, 142, 123, 216, 219, 233, 248, 89 + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 ] } } @@ -883,11 +1558,29 @@ "accounts": [ { "name": "Global", - "discriminator": [167, 232, 232, 177, 200, 108, 114, 127] + "discriminator": [ + 167, + 232, + 232, + 177, + 200, + 108, + 114, + 127 + ] }, { "name": "SwapGlobal", - "discriminator": [15, 184, 147, 129, 183, 219, 223, 163] + "discriminator": [ + 15, + 184, + 147, + 129, + 183, + 219, + 223, + 163 + ] } ], "errors": [ @@ -971,7 +1664,10 @@ { "name": "earner_merkle_root", "type": { - "array": ["u8", 32] + "array": [ + "u8", + 32 + ] } }, { @@ -1021,4 +1717,4 @@ "value": "[103, 108, 111, 98, 97, 108]" } ] -} +} \ No newline at end of file diff --git a/services/api/server/src/programs/ext_swap.ts b/services/api/server/src/programs/ext_swap.ts index 26811a53..950aca55 100644 --- a/services/api/server/src/programs/ext_swap.ts +++ b/services/api/server/src/programs/ext_swap.ts @@ -5,176 +5,265 @@ * IDL can be found at `target/idl/ext_swap.json`. */ export type ExtSwap = { - address: 'MSwapi3WhNKMUGm9YrxGhypgUEt7wYQH3ZgG32XoWzH'; - metadata: { - name: 'extSwap'; - version: '0.1.0'; - spec: '0.1.0'; - description: 'Created with Anchor'; - }; - instructions: [ + "address": "MSwapi3WhNKMUGm9YrxGhypgUEt7wYQH3ZgG32XoWzH", + "metadata": { + "name": "extSwap", + "version": "0.1.0", + "spec": "0.1.0", + "description": "Created with Anchor" + }, + "instructions": [ { - name: 'initializeGlobal'; - discriminator: [47, 225, 15, 112, 86, 51, 190, 231]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - }, - { - name: 'swapGlobal'; - writable: true; - pda: { - seeds: [ + "name": "initializeGlobal", + "discriminator": [ + 47, + 225, + 15, + 112, + 86, + 51, + 190, + 231 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true + }, + { + "name": "swapGlobal", + "writable": true, + "pda": { + "seeds": [ { - kind: 'const'; - value: [103, 108, 111, 98, 97, 108]; - }, - ]; - }; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: []; + "kind": "const", + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] + } + ] + } + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [] }, { - name: 'removeWhitelistedExtension'; - discriminator: [248, 52, 115, 71, 67, 42, 71, 252]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - relations: ['swapGlobal']; - }, - { - name: 'swapGlobal'; - writable: true; - pda: { - seeds: [ + "name": "removeWhitelistedExtension", + "discriminator": [ + 248, + 52, + 115, + 71, + 67, + 42, + 71, + 252 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "swapGlobal" + ] + }, + { + "name": "swapGlobal", + "writable": true, + "pda": { + "seeds": [ { - kind: 'const'; - value: [103, 108, 111, 98, 97, 108]; - }, - ]; - }; - }, - ]; - args: [ - { - name: 'extProgram'; - type: 'pubkey'; - }, - ]; + "kind": "const", + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] + } + ] + } + } + ], + "args": [ + { + "name": "extProgram", + "type": "pubkey" + } + ] }, { - name: 'removeWhitelistedUnwrapper'; - discriminator: [166, 23, 120, 95, 66, 168, 192, 163]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - relations: ['swapGlobal']; - }, - { - name: 'swapGlobal'; - writable: true; - pda: { - seeds: [ + "name": "removeWhitelistedUnwrapper", + "discriminator": [ + 166, + 23, + 120, + 95, + 66, + 168, + 192, + 163 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "swapGlobal" + ] + }, + { + "name": "swapGlobal", + "writable": true, + "pda": { + "seeds": [ { - kind: 'const'; - value: [103, 108, 111, 98, 97, 108]; - }, - ]; - }; - }, - ]; - args: [ - { - name: 'authority'; - type: 'pubkey'; - }, - ]; + "kind": "const", + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] + } + ] + } + } + ], + "args": [ + { + "name": "authority", + "type": "pubkey" + } + ] }, { - name: 'swap'; - discriminator: [248, 198, 158, 145, 225, 117, 135, 200]; - accounts: [ + "name": "swap", + "discriminator": [ + 248, + 198, + 158, + 145, + 225, + 117, + 135, + 200 + ], + "accounts": [ { - name: 'signer'; - writable: true; - signer: true; + "name": "signer", + "writable": true, + "signer": true }, { - name: 'wrapAuthority'; - signer: true; - optional: true; + "name": "wrapAuthority", + "signer": true, + "optional": true }, { - name: 'unwrapAuthority'; - signer: true; - optional: true; + "name": "unwrapAuthority", + "signer": true, + "optional": true }, { - name: 'swapGlobal'; - pda: { - seeds: [ + "name": "swapGlobal", + "pda": { + "seeds": [ { - kind: 'const'; - value: [103, 108, 111, 98, 97, 108]; - }, - ]; - }; - }, - { - name: 'fromGlobal'; - writable: true; - pda: { - seeds: [ + "kind": "const", + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] + } + ] + } + }, + { + "name": "fromGlobal", + "writable": true, + "pda": { + "seeds": [ { - kind: 'const'; - value: [103, 108, 111, 98, 97, 108]; - }, - ]; - program: { - kind: 'account'; - path: 'fromExtProgram'; - }; - }; - }, - { - name: 'toGlobal'; - writable: true; - pda: { - seeds: [ + "kind": "const", + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] + } + ], + "program": { + "kind": "account", + "path": "fromExtProgram" + } + } + }, + { + "name": "toGlobal", + "writable": true, + "pda": { + "seeds": [ { - kind: 'const'; - value: [103, 108, 111, 98, 97, 108]; - }, - ]; - program: { - kind: 'account'; - path: 'toExtProgram'; - }; - }; - }, - { - name: 'mGlobal'; - pda: { - seeds: [ + "kind": "const", + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] + } + ], + "program": { + "kind": "account", + "path": "toExtProgram" + } + } + }, + { + "name": "mGlobal", + "pda": { + "seeds": [ { - kind: 'const'; - value: [103, 108, 111, 98, 97, 108]; - }, - ]; - program: { - kind: 'const'; - value: [ + "kind": "const", + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] + } + ], + "program": { + "kind": "const", + "value": [ 5, 96, 203, @@ -206,49 +295,53 @@ export type ExtSwap = { 130, 244, 142, - 245, - ]; - }; - }; + 245 + ] + } + } }, { - name: 'fromMint'; - docs: ['Validated by unwrap on the extension program']; - writable: true; + "name": "fromMint", + "docs": [ + "Validated by unwrap on the extension program" + ], + "writable": true }, { - name: 'toMint'; - docs: ['Validated by wrap on the extension program']; - writable: true; + "name": "toMint", + "docs": [ + "Validated by wrap on the extension program" + ], + "writable": true }, { - name: 'mMint'; + "name": "mMint" }, { - name: 'fromTokenAccount'; - writable: true; + "name": "fromTokenAccount", + "writable": true }, { - name: 'toTokenAccount'; - writable: true; - pda: { - seeds: [ + "name": "toTokenAccount", + "writable": true, + "pda": { + "seeds": [ { - kind: 'account'; - path: 'signer'; + "kind": "account", + "path": "signer" }, { - kind: 'account'; - path: 'toTokenProgram'; + "kind": "account", + "path": "toTokenProgram" }, { - kind: 'account'; - path: 'toMint'; - }, - ]; - program: { - kind: 'const'; - value: [ + "kind": "account", + "path": "toMint" + } + ], + "program": { + "kind": "const", + "value": [ 140, 151, 37, @@ -280,32 +373,32 @@ export type ExtSwap = { 219, 233, 248, - 89, - ]; - }; - }; + 89 + ] + } + } }, { - name: 'intermediateMAccount'; - writable: true; - pda: { - seeds: [ + "name": "intermediateMAccount", + "writable": true, + "pda": { + "seeds": [ { - kind: 'account'; - path: 'signer'; + "kind": "account", + "path": "signer" }, { - kind: 'account'; - path: 'mTokenProgram'; + "kind": "account", + "path": "mTokenProgram" }, { - kind: 'account'; - path: 'mMint'; - }, - ]; - program: { - kind: 'const'; - value: [ + "kind": "account", + "path": "mMint" + } + ], + "program": { + "kind": "const", + "value": [ 140, 151, 37, @@ -337,98 +430,144 @@ export type ExtSwap = { 219, 233, 248, - 89, - ]; - }; - }; + 89 + ] + } + } }, { - name: 'fromMVaultAuth'; - pda: { - seeds: [ + "name": "fromMVaultAuth", + "pda": { + "seeds": [ { - kind: 'const'; - value: [109, 95, 118, 97, 117, 108, 116]; - }, - ]; - program: { - kind: 'account'; - path: 'fromExtProgram'; - }; - }; - }, - { - name: 'toMVaultAuth'; - pda: { - seeds: [ + "kind": "const", + "value": [ + 109, + 95, + 118, + 97, + 117, + 108, + 116 + ] + } + ], + "program": { + "kind": "account", + "path": "fromExtProgram" + } + } + }, + { + "name": "toMVaultAuth", + "pda": { + "seeds": [ { - kind: 'const'; - value: [109, 95, 118, 97, 117, 108, 116]; - }, - ]; - program: { - kind: 'account'; - path: 'toExtProgram'; - }; - }; - }, - { - name: 'fromMintAuthority'; - pda: { - seeds: [ + "kind": "const", + "value": [ + 109, + 95, + 118, + 97, + 117, + 108, + 116 + ] + } + ], + "program": { + "kind": "account", + "path": "toExtProgram" + } + } + }, + { + "name": "fromMintAuthority", + "pda": { + "seeds": [ { - kind: 'const'; - value: [109, 105, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121]; - }, - ]; - program: { - kind: 'account'; - path: 'fromExtProgram'; - }; - }; - }, - { - name: 'toMintAuthority'; - pda: { - seeds: [ + "kind": "const", + "value": [ + 109, + 105, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ], + "program": { + "kind": "account", + "path": "fromExtProgram" + } + } + }, + { + "name": "toMintAuthority", + "pda": { + "seeds": [ { - kind: 'const'; - value: [109, 105, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121]; - }, - ]; - program: { - kind: 'account'; - path: 'toExtProgram'; - }; - }; - }, - { - name: 'fromMEarnerAccount'; - }, - { - name: 'toMEarnerAccount'; - }, - { - name: 'fromMVault'; - writable: true; - pda: { - seeds: [ + "kind": "const", + "value": [ + 109, + 105, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ], + "program": { + "kind": "account", + "path": "toExtProgram" + } + } + }, + { + "name": "fromMEarnerAccount" + }, + { + "name": "toMEarnerAccount" + }, + { + "name": "fromMVault", + "writable": true, + "pda": { + "seeds": [ { - kind: 'account'; - path: 'fromMVaultAuth'; + "kind": "account", + "path": "fromMVaultAuth" }, { - kind: 'account'; - path: 'mTokenProgram'; + "kind": "account", + "path": "mTokenProgram" }, { - kind: 'account'; - path: 'mMint'; - }, - ]; - program: { - kind: 'const'; - value: [ + "kind": "account", + "path": "mMint" + } + ], + "program": { + "kind": "const", + "value": [ 140, 151, 37, @@ -460,32 +599,32 @@ export type ExtSwap = { 219, 233, 248, - 89, - ]; - }; - }; + 89 + ] + } + } }, { - name: 'toMVault'; - writable: true; - pda: { - seeds: [ + "name": "toMVault", + "writable": true, + "pda": { + "seeds": [ { - kind: 'account'; - path: 'toMVaultAuth'; + "kind": "account", + "path": "toMVaultAuth" }, { - kind: 'account'; - path: 'mTokenProgram'; + "kind": "account", + "path": "mTokenProgram" }, { - kind: 'account'; - path: 'mMint'; - }, - ]; - program: { - kind: 'const'; - value: [ + "kind": "account", + "path": "mMint" + } + ], + "program": { + "kind": "const", + "value": [ 140, 151, 37, @@ -517,99 +656,129 @@ export type ExtSwap = { 219, 233, 248, - 89, - ]; - }; - }; + 89 + ] + } + } }, { - name: 'fromTokenProgram'; + "name": "fromTokenProgram" }, { - name: 'toTokenProgram'; + "name": "toTokenProgram" }, { - name: 'mTokenProgram'; + "name": "mTokenProgram" }, { - name: 'fromExtProgram'; + "name": "fromExtProgram" }, { - name: 'toExtProgram'; + "name": "toExtProgram" }, { - name: 'associatedTokenProgram'; - address: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'; + "name": "associatedTokenProgram", + "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" }, { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ { - name: 'amount'; - type: 'u64'; + "name": "amount", + "type": "u64" }, { - name: 'remainingAccountsSplitIdx'; - type: 'u8'; - }, - ]; + "name": "remainingAccountsSplitIdx", + "type": "u8" + } + ] }, { - name: 'unwrap'; - discriminator: [126, 175, 198, 14, 212, 69, 50, 44]; - accounts: [ - { - name: 'signer'; - writable: true; - signer: true; - }, - { - name: 'unwrapAuthority'; - signer: true; - optional: true; - }, - { - name: 'swapGlobal'; - pda: { - seeds: [ + "name": "unwrap", + "discriminator": [ + 126, + 175, + 198, + 14, + 212, + 69, + 50, + 44 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "unwrapAuthority", + "signer": true, + "optional": true + }, + { + "name": "swapGlobal", + "pda": { + "seeds": [ { - kind: 'const'; - value: [103, 108, 111, 98, 97, 108]; - }, - ]; - }; - }, - { - name: 'fromGlobal'; - writable: true; - pda: { - seeds: [ + "kind": "const", + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] + } + ] + } + }, + { + "name": "fromGlobal", + "writable": true, + "pda": { + "seeds": [ { - kind: 'const'; - value: [103, 108, 111, 98, 97, 108]; - }, - ]; - program: { - kind: 'account'; - path: 'fromExtProgram'; - }; - }; - }, - { - name: 'mGlobal'; - pda: { - seeds: [ + "kind": "const", + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] + } + ], + "program": { + "kind": "account", + "path": "fromExtProgram" + } + } + }, + { + "name": "mGlobal", + "pda": { + "seeds": [ { - kind: 'const'; - value: [103, 108, 111, 98, 97, 108]; - }, - ]; - program: { - kind: 'const'; - value: [ + "kind": "const", + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] + } + ], + "program": { + "kind": "const", + "value": [ 5, 96, 203, @@ -641,40 +810,42 @@ export type ExtSwap = { 130, 244, 142, - 245, - ]; - }; - }; + 245 + ] + } + } }, { - name: 'fromMint'; - docs: ['Validated by unwrap on the extension program']; - writable: true; + "name": "fromMint", + "docs": [ + "Validated by unwrap on the extension program" + ], + "writable": true }, { - name: 'mMint'; + "name": "mMint" }, { - name: 'mTokenAccount'; - writable: true; - pda: { - seeds: [ + "name": "mTokenAccount", + "writable": true, + "pda": { + "seeds": [ { - kind: 'account'; - path: 'signer'; + "kind": "account", + "path": "signer" }, { - kind: 'account'; - path: 'mTokenProgram'; + "kind": "account", + "path": "mTokenProgram" }, { - kind: 'account'; - path: 'mMint'; - }, - ]; - program: { - kind: 'const'; - value: [ + "kind": "account", + "path": "mMint" + } + ], + "program": { + "kind": "const", + "value": [ 140, 151, 37, @@ -706,32 +877,32 @@ export type ExtSwap = { 219, 233, 248, - 89, - ]; - }; - }; + 89 + ] + } + } }, { - name: 'fromTokenAccount'; - writable: true; - pda: { - seeds: [ + "name": "fromTokenAccount", + "writable": true, + "pda": { + "seeds": [ { - kind: 'account'; - path: 'signer'; + "kind": "account", + "path": "signer" }, { - kind: 'account'; - path: 'fromTokenProgram'; + "kind": "account", + "path": "fromTokenProgram" }, { - kind: 'account'; - path: 'fromMint'; - }, - ]; - program: { - kind: 'const'; - value: [ + "kind": "account", + "path": "fromMint" + } + ], + "program": { + "kind": "const", + "value": [ 140, 151, 37, @@ -763,62 +934,85 @@ export type ExtSwap = { 219, 233, 248, - 89, - ]; - }; - }; + 89 + ] + } + } }, { - name: 'fromMVaultAuth'; - pda: { - seeds: [ + "name": "fromMVaultAuth", + "pda": { + "seeds": [ { - kind: 'const'; - value: [109, 95, 118, 97, 117, 108, 116]; - }, - ]; - program: { - kind: 'account'; - path: 'fromExtProgram'; - }; - }; - }, - { - name: 'fromMintAuthority'; - pda: { - seeds: [ + "kind": "const", + "value": [ + 109, + 95, + 118, + 97, + 117, + 108, + 116 + ] + } + ], + "program": { + "kind": "account", + "path": "fromExtProgram" + } + } + }, + { + "name": "fromMintAuthority", + "pda": { + "seeds": [ { - kind: 'const'; - value: [109, 105, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121]; - }, - ]; - program: { - kind: 'account'; - path: 'fromExtProgram'; - }; - }; - }, - { - name: 'fromMVault'; - writable: true; - pda: { - seeds: [ + "kind": "const", + "value": [ + 109, + 105, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ], + "program": { + "kind": "account", + "path": "fromExtProgram" + } + } + }, + { + "name": "fromMVault", + "writable": true, + "pda": { + "seeds": [ { - kind: 'account'; - path: 'fromMVaultAuth'; + "kind": "account", + "path": "fromMVaultAuth" }, { - kind: 'account'; - path: 'mTokenProgram'; + "kind": "account", + "path": "mTokenProgram" }, { - kind: 'account'; - path: 'mMint'; - }, - ]; - program: { - kind: 'const'; - value: [ + "kind": "account", + "path": "mMint" + } + ], + "program": { + "kind": "const", + "value": [ 140, 151, 37, @@ -850,158 +1044,224 @@ export type ExtSwap = { 219, 233, 248, - 89, - ]; - }; - }; + 89 + ] + } + } }, { - name: 'fromMEarnerAccount'; + "name": "fromMEarnerAccount" }, { - name: 'fromTokenProgram'; + "name": "fromTokenProgram" }, { - name: 'mTokenProgram'; + "name": "mTokenProgram" }, { - name: 'fromExtProgram'; + "name": "fromExtProgram" }, { - name: 'associatedTokenProgram'; - address: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'; + "name": "associatedTokenProgram", + "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" }, { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ { - name: 'amount'; - type: 'u64'; - }, - ]; + "name": "amount", + "type": "u64" + } + ] }, { - name: 'whitelistExtension'; - discriminator: [186, 175, 23, 231, 77, 201, 205, 165]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - relations: ['swapGlobal']; - }, - { - name: 'swapGlobal'; - writable: true; - pda: { - seeds: [ + "name": "whitelistExtension", + "discriminator": [ + 186, + 175, + 23, + 231, + 77, + 201, + 205, + 165 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "swapGlobal" + ] + }, + { + "name": "swapGlobal", + "writable": true, + "pda": { + "seeds": [ { - kind: 'const'; - value: [103, 108, 111, 98, 97, 108]; - }, - ]; - }; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - { - name: 'extProgram'; - }, - ]; - args: []; + "kind": "const", + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] + } + ] + } + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "extProgram" + } + ], + "args": [] }, { - name: 'whitelistUnwrapper'; - discriminator: [219, 87, 23, 47, 189, 191, 123, 235]; - accounts: [ - { - name: 'admin'; - writable: true; - signer: true; - relations: ['swapGlobal']; - }, - { - name: 'swapGlobal'; - writable: true; - pda: { - seeds: [ + "name": "whitelistUnwrapper", + "discriminator": [ + 219, + 87, + 23, + 47, + 189, + 191, + 123, + 235 + ], + "accounts": [ + { + "name": "admin", + "writable": true, + "signer": true, + "relations": [ + "swapGlobal" + ] + }, + { + "name": "swapGlobal", + "writable": true, + "pda": { + "seeds": [ { - kind: 'const'; - value: [103, 108, 111, 98, 97, 108]; - }, - ]; - }; - }, - { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ - { - name: 'authority'; - type: 'pubkey'; - }, - ]; + "kind": "const", + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] + } + ] + } + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "authority", + "type": "pubkey" + } + ] }, { - name: 'wrap'; - discriminator: [178, 40, 10, 189, 228, 129, 186, 140]; - accounts: [ - { - name: 'signer'; - writable: true; - signer: true; - }, - { - name: 'wrapAuthority'; - signer: true; - optional: true; - }, - { - name: 'swapGlobal'; - pda: { - seeds: [ + "name": "wrap", + "discriminator": [ + 178, + 40, + 10, + 189, + 228, + 129, + 186, + 140 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "wrapAuthority", + "signer": true, + "optional": true + }, + { + "name": "swapGlobal", + "pda": { + "seeds": [ { - kind: 'const'; - value: [103, 108, 111, 98, 97, 108]; - }, - ]; - }; - }, - { - name: 'toGlobal'; - writable: true; - pda: { - seeds: [ + "kind": "const", + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] + } + ] + } + }, + { + "name": "toGlobal", + "writable": true, + "pda": { + "seeds": [ { - kind: 'const'; - value: [103, 108, 111, 98, 97, 108]; - }, - ]; - program: { - kind: 'account'; - path: 'toExtProgram'; - }; - }; - }, - { - name: 'mGlobal'; - pda: { - seeds: [ + "kind": "const", + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] + } + ], + "program": { + "kind": "account", + "path": "toExtProgram" + } + } + }, + { + "name": "mGlobal", + "pda": { + "seeds": [ { - kind: 'const'; - value: [103, 108, 111, 98, 97, 108]; - }, - ]; - program: { - kind: 'const'; - value: [ + "kind": "const", + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] + } + ], + "program": { + "kind": "const", + "value": [ 5, 96, 203, @@ -1033,40 +1293,42 @@ export type ExtSwap = { 130, 244, 142, - 245, - ]; - }; - }; + 245 + ] + } + } }, { - name: 'toMint'; - docs: ['Validated by wrap on the extension program']; - writable: true; + "name": "toMint", + "docs": [ + "Validated by wrap on the extension program" + ], + "writable": true }, { - name: 'mMint'; + "name": "mMint" }, { - name: 'mTokenAccount'; - writable: true; - pda: { - seeds: [ + "name": "mTokenAccount", + "writable": true, + "pda": { + "seeds": [ { - kind: 'account'; - path: 'signer'; + "kind": "account", + "path": "signer" }, { - kind: 'account'; - path: 'mTokenProgram'; + "kind": "account", + "path": "mTokenProgram" }, { - kind: 'account'; - path: 'mMint'; - }, - ]; - program: { - kind: 'const'; - value: [ + "kind": "account", + "path": "mMint" + } + ], + "program": { + "kind": "const", + "value": [ 140, 151, 37, @@ -1098,32 +1360,32 @@ export type ExtSwap = { 219, 233, 248, - 89, - ]; - }; - }; + 89 + ] + } + } }, { - name: 'toTokenAccount'; - writable: true; - pda: { - seeds: [ + "name": "toTokenAccount", + "writable": true, + "pda": { + "seeds": [ { - kind: 'account'; - path: 'signer'; + "kind": "account", + "path": "signer" }, { - kind: 'account'; - path: 'toTokenProgram'; + "kind": "account", + "path": "toTokenProgram" }, { - kind: 'account'; - path: 'toMint'; - }, - ]; - program: { - kind: 'const'; - value: [ + "kind": "account", + "path": "toMint" + } + ], + "program": { + "kind": "const", + "value": [ 140, 151, 37, @@ -1155,62 +1417,85 @@ export type ExtSwap = { 219, 233, 248, - 89, - ]; - }; - }; + 89 + ] + } + } }, { - name: 'toMVaultAuth'; - pda: { - seeds: [ + "name": "toMVaultAuth", + "pda": { + "seeds": [ { - kind: 'const'; - value: [109, 95, 118, 97, 117, 108, 116]; - }, - ]; - program: { - kind: 'account'; - path: 'toExtProgram'; - }; - }; - }, - { - name: 'toMintAuthority'; - pda: { - seeds: [ + "kind": "const", + "value": [ + 109, + 95, + 118, + 97, + 117, + 108, + 116 + ] + } + ], + "program": { + "kind": "account", + "path": "toExtProgram" + } + } + }, + { + "name": "toMintAuthority", + "pda": { + "seeds": [ { - kind: 'const'; - value: [109, 105, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121]; - }, - ]; - program: { - kind: 'account'; - path: 'toExtProgram'; - }; - }; - }, - { - name: 'toMVault'; - writable: true; - pda: { - seeds: [ + "kind": "const", + "value": [ + 109, + 105, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ], + "program": { + "kind": "account", + "path": "toExtProgram" + } + } + }, + { + "name": "toMVault", + "writable": true, + "pda": { + "seeds": [ { - kind: 'account'; - path: 'toMVaultAuth'; + "kind": "account", + "path": "toMVaultAuth" }, { - kind: 'account'; - path: 'mTokenProgram'; + "kind": "account", + "path": "mTokenProgram" }, { - kind: 'account'; - path: 'mMint'; - }, - ]; - program: { - kind: 'const'; - value: [ + "kind": "account", + "path": "mMint" + } + ], + "program": { + "kind": "const", + "value": [ 140, 151, 37, @@ -1242,179 +1527,200 @@ export type ExtSwap = { 219, 233, 248, - 89, - ]; - }; - }; + 89 + ] + } + } }, { - name: 'toMEarnerAccount'; + "name": "toMEarnerAccount" }, { - name: 'toTokenProgram'; + "name": "toTokenProgram" }, { - name: 'mTokenProgram'; + "name": "mTokenProgram" }, { - name: 'toExtProgram'; + "name": "toExtProgram" }, { - name: 'associatedTokenProgram'; - address: 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'; + "name": "associatedTokenProgram", + "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" }, { - name: 'systemProgram'; - address: '11111111111111111111111111111111'; - }, - ]; - args: [ + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ { - name: 'amount'; - type: 'u64'; - }, - ]; - }, - ]; - accounts: [ + "name": "amount", + "type": "u64" + } + ] + } + ], + "accounts": [ { - name: 'global'; - discriminator: [167, 232, 232, 177, 200, 108, 114, 127]; + "name": "global", + "discriminator": [ + 167, + 232, + 232, + 177, + 200, + 108, + 114, + 127 + ] }, { - name: 'swapGlobal'; - discriminator: [15, 184, 147, 129, 183, 219, 223, 163]; - }, - ]; - errors: [ + "name": "swapGlobal", + "discriminator": [ + 15, + 184, + 147, + 129, + 183, + 219, + 223, + 163 + ] + } + ], + "errors": [ { - code: 6000; - name: 'invalidExtension'; - msg: 'Extension is not whitelisted'; + "code": 6000, + "name": "invalidExtension", + "msg": "Extension is not whitelisted" }, { - code: 6001; - name: 'alreadyWhitelisted'; - msg: 'Extension is already whitelisted'; + "code": 6001, + "name": "alreadyWhitelisted", + "msg": "Extension is already whitelisted" }, { - code: 6002; - name: 'invalidIndex'; - msg: 'Index invalid for length of the array'; + "code": 6002, + "name": "invalidIndex", + "msg": "Index invalid for length of the array" }, { - code: 6003; - name: 'unauthorizedUnwrapper'; - msg: 'Signer is not whitelisted'; + "code": 6003, + "name": "unauthorizedUnwrapper", + "msg": "Signer is not whitelisted" }, { - code: 6004; - name: 'notAuthorized'; - msg: 'Signer is not authorized to perform this action'; + "code": 6004, + "name": "notAuthorized", + "msg": "Signer is not authorized to perform this action" }, { - code: 6005; - name: 'invalidAmount'; - msg: 'Invalid amount'; - }, - ]; - types: [ + "code": 6005, + "name": "invalidAmount", + "msg": "Invalid amount" + } + ], + "types": [ { - name: 'global'; - type: { - kind: 'struct'; - fields: [ + "name": "global", + "type": { + "kind": "struct", + "fields": [ { - name: 'admin'; - type: 'pubkey'; + "name": "admin", + "type": "pubkey" }, { - name: 'earnAuthority'; - type: 'pubkey'; + "name": "earnAuthority", + "type": "pubkey" }, { - name: 'mint'; - type: 'pubkey'; + "name": "mint", + "type": "pubkey" }, { - name: 'index'; - type: 'u64'; + "name": "index", + "type": "u64" }, { - name: 'timestamp'; - type: 'u64'; + "name": "timestamp", + "type": "u64" }, { - name: 'claimCooldown'; - type: 'u64'; + "name": "claimCooldown", + "type": "u64" }, { - name: 'maxSupply'; - type: 'u64'; + "name": "maxSupply", + "type": "u64" }, { - name: 'maxYield'; - type: 'u64'; + "name": "maxYield", + "type": "u64" }, { - name: 'distributed'; - type: 'u64'; + "name": "distributed", + "type": "u64" }, { - name: 'claimComplete'; - type: 'bool'; + "name": "claimComplete", + "type": "bool" }, { - name: 'earnerMerkleRoot'; - type: { - array: ['u8', 32]; - }; + "name": "earnerMerkleRoot", + "type": { + "array": [ + "u8", + 32 + ] + } }, { - name: 'portalAuthority'; - type: 'pubkey'; + "name": "portalAuthority", + "type": "pubkey" }, { - name: 'bump'; - type: 'u8'; - }, - ]; - }; + "name": "bump", + "type": "u8" + } + ] + } }, { - name: 'swapGlobal'; - type: { - kind: 'struct'; - fields: [ + "name": "swapGlobal", + "type": { + "kind": "struct", + "fields": [ { - name: 'bump'; - type: 'u8'; + "name": "bump", + "type": "u8" }, { - name: 'admin'; - type: 'pubkey'; + "name": "admin", + "type": "pubkey" }, { - name: 'whitelistedUnwrappers'; - type: { - vec: 'pubkey'; - }; + "name": "whitelistedUnwrappers", + "type": { + "vec": "pubkey" + } }, { - name: 'whitelistedExtensions'; - type: { - vec: 'pubkey'; - }; - }, - ]; - }; - }, - ]; - constants: [ + "name": "whitelistedExtensions", + "type": { + "vec": "pubkey" + } + } + ] + } + } + ], + "constants": [ { - name: 'globalSeed'; - type: 'bytes'; - value: '[103, 108, 111, 98, 97, 108]'; - }, - ]; + "name": "globalSeed", + "type": "bytes", + "value": "[103, 108, 111, 98, 97, 108]" + } + ] }; diff --git a/services/api/server/src/server.ts b/services/api/server/src/server.ts index 4d18563b..026f1b26 100644 --- a/services/api/server/src/server.ts +++ b/services/api/server/src/server.ts @@ -9,7 +9,7 @@ import { events } from './events'; import { connectToDatabase } from './db'; import { tokenAccount } from './tokenAccount'; import { extensions } from './extensions'; -import { swap } from './swap'; +import { transactions } from './transactions'; const PORT = process.env.PORT ?? 5500; @@ -29,7 +29,7 @@ if (process.env.DISABLE_CACHE === 'true') { // basic rate limiting to swap endpoints app.use( - '/swap', + '/transaction', rateLimit({ windowMs: 5_000, limit: 5, @@ -49,7 +49,7 @@ connectToDatabase() app.use('/docs', docs); // register all services implementation in api spec -register(app, { events, tokenAccount, extensions, swap }); +register(app, { events, tokenAccount, extensions, transactions }); app.listen(PORT); logger.info('Server is running', { port: `${PORT}` }); diff --git a/services/api/server/src/swap.ts b/services/api/server/src/transactions.ts similarity index 65% rename from services/api/server/src/swap.ts rename to services/api/server/src/transactions.ts index f9e46dd1..763f855c 100644 --- a/services/api/server/src/swap.ts +++ b/services/api/server/src/transactions.ts @@ -1,10 +1,12 @@ -import { SwapService } from '../generated/api/resources/swap/service/SwapService'; +import { TransactionsService } from '../generated/api/resources/transactions/service/TransactionsService'; import NodeCache from 'node-cache'; import { createJupiterApiClient, Instruction, QuoteResponse, RoutePlanStep } from '@jup-ag/api'; -import { BadQuoteRequest, QuoteNotFound, RoutePlan, SimulationFailed } from '../generated/api'; +import { BadBridgeRequest, BadQuoteRequest, QuoteNotFound, RoutePlan, SimulationFailed } from '../generated/api'; import { AddressLookupTableAccount, Connection, + Keypair, + LAMPORTS_PER_SOL, PublicKey, SimulatedTransactionResponse, TransactionInstruction, @@ -22,6 +24,10 @@ import { } from '@solana-program/token-2022'; import { BN } from '@coral-xyz/anchor'; import { createSolanaRpc, Address, isSome, Account } from '@solana/kit'; +import { createApproveInstruction, getAssociatedTokenAddress, TOKEN_2022_PROGRAM_ID } from '@solana/spl-token'; +import { UniversalAddress, Wormhole } from '@wormhole-foundation/sdk'; +import { NTT, SolanaNtt } from '@wormhole-foundation/sdk-solana-ntt'; +import solana from '@wormhole-foundation/sdk/platforms/solana'; import { logger } from './server'; const quoteCache = new NodeCache({ stdTTL: 90 }); @@ -31,6 +37,7 @@ const swapProgram = getSwapProgram(connection); const MAX_ACCOUNTS = process.env.MAX_JUP_ACCOUNTS ? parseInt(process.env.MAX_JUP_ACCOUNTS) : 48; const SWAP_LUT = new PublicKey('9JLRqBqkznKiSoNfotA4ywSRdnWb2fE76SiFrAfkaRCD'); +const EARN = new PublicKey('MzeRokYa9o1ZikH6XHRiSS5nD8mNjZyHpLCBRTBSY4c'); const wM = new PublicKey('mzeroXDoBpRVhnEXBra27qzAMdxgpWVY3DzQW7xMVJp'); type extension = { @@ -47,9 +54,9 @@ type Quote = { swapFacilityAmount?: string; }; -export const swap = new SwapService({ +export const transactions = new TransactionsService({ quote: async (req, res, next) => { - const { inputMint, outputMint, amount, slippageBps } = req.query; + const { inputMint, outputMint, amount, slippageBps, maxAccounts } = req.query; const slippage = slippageBps ?? 50; // generate random id and save quote for swap endpoint @@ -94,7 +101,7 @@ export const swap = new SwapService({ quoteResponse.preQuote = quote; routePlan.push(...quote.routePlan.map(convertRoutePlan)); - routePlan.push(getM0Route(wM.toBase58(), outputMint, quote.outAmount)); + if (outputMint !== wM.toBase58()) routePlan.push(getM0Route(wM.toBase58(), outputMint, quote.outAmount)); // minimum output amount after accounting for `slippageBps` and `platformFeeBps` quoteResponse.swapFacilityAmount = quote.otherAmountThreshold; @@ -125,7 +132,7 @@ export const swap = new SwapService({ outputMint, amount: parseInt(amount), slippageBps: slippage, - maxAccounts: MAX_ACCOUNTS, + maxAccounts: maxAccounts ?? MAX_ACCOUNTS, }); quoteResponse.preQuote = quote; @@ -206,6 +213,22 @@ export const swap = new SwapService({ const luts = [SWAP_LUT]; const ixs: TransactionInstruction[] = []; + const resolveEarnerAccount = async (programId: string) => { + const [vaultTokenAccount] = await findAssociatedTokenPda({ + mint: mMint, + owner: PublicKey.findProgramAddressSync( + [Buffer.from('m_vault')], + new PublicKey(programId), + )[0].toBase58() as Address, + tokenProgram: TOKEN_2022_PROGRAM_ADDRESS, + }); + const [earnerAccount] = PublicKey.findProgramAddressSync( + [Buffer.from('earner'), new PublicKey(vaultTokenAccount).toBytes()], + EARN, + ); + return earnerAccount; + }; + // wrapping if (isWrap) { ixs.push( @@ -219,6 +242,7 @@ export const swap = new SwapService({ mMint: mMint, toTokenProgram: TOKEN_2022_PROGRAM_ADDRESS, mTokenProgram: TOKEN_2022_PROGRAM_ADDRESS, + toMEarnerAccount: await resolveEarnerAccount(quote.extensionTo!.programId), }) .instruction(), ); @@ -237,6 +261,7 @@ export const swap = new SwapService({ mMint: mMint, fromTokenProgram: TOKEN_2022_PROGRAM_ADDRESS, mTokenProgram: TOKEN_2022_PROGRAM_ADDRESS, + fromMEarnerAccount: await resolveEarnerAccount(quote.extensionFrom!.programId), }) .instruction(), ); @@ -259,8 +284,8 @@ export const swap = new SwapService({ ); } - // swap if we are not wrapping or unwrapping - if (!isWrap && !isUnwrap) { + // swap if we are not wrapping or unwrapping (and not already wM) + if (!isWrap && !isUnwrap && quote.extensionTo?.mint !== wM.toBase58()) { const [associatedTokenAddress] = await findAssociatedTokenPda({ mint: quote.extensionFrom!.mint as Address, owner: userPublicKey as Address, @@ -284,6 +309,8 @@ export const swap = new SwapService({ toTokenProgram: TOKEN_2022_PROGRAM_ADDRESS, mTokenProgram: TOKEN_2022_PROGRAM_ADDRESS, fromTokenProgram: TOKEN_2022_PROGRAM_ADDRESS, + toMEarnerAccount: await resolveEarnerAccount(quote.extensionTo!.programId), + fromMEarnerAccount: await resolveEarnerAccount(quote.extensionFrom!.programId), }) .instruction(), ); @@ -306,49 +333,146 @@ export const swap = new SwapService({ ); } - // resolve lut accounts - const addressLookupTableAccounts = await getAddressLookupTableAccounts(luts); + const { logs, b64, formattedInstructions } = await buildTransaction(userPublicKey, ixs, luts); - const blockhash = (await connection.getLatestBlockhash({ commitment: 'finalized' })).blockhash; - const messageV0 = new TransactionMessage({ - payerKey: new PublicKey(userPublicKey), - recentBlockhash: blockhash, - instructions: ixs, - }).compileToV0Message(addressLookupTableAccounts); + res.send({ + transaction: b64, + simulationLogs: logs, + luts: luts.map((lut) => lut.toBase58()), + instructions: formattedInstructions, + }); + }, - const transaction = new VersionedTransaction(messageV0); + bridge: async (req, res, next) => { + const { userPublicKey, amount, fromChain, toChain, recipientAddress, outboxItem } = req.query; + const sender = new PublicKey(userPublicKey); - let sim: SimulatedTransactionResponse; - try { - sim = (await connection.simulateTransaction(transaction, { replaceRecentBlockhash: true })).value; - } catch (error) { - throw new SimulationFailed({ - message: `Simulation failed: ${error}`, - }); + if (fromChain !== 'Solana') { + throw new BadBridgeRequest({ message: 'Only Solana to EVM bridging is supported ATM' }); + } + if (fromChain === toChain) { + throw new BadBridgeRequest({ message: 'Cannot bridge to the same chain' }); + } + if (fromChain === 'Solana' && !outboxItem) { + throw new BadBridgeRequest({ message: 'Outbox item is required when bridging from Solana' }); } - const logs = sim.logs || []; - const b64 = Buffer.from(transaction.serialize()).toString('base64'); - - if (sim.err) { - logger.error('Swap simulation failed', { logs, quoteId, userPublicKey, b64 }); + const ixs: TransactionInstruction[] = []; + const ntt = NttManager(); + const outboxItemPubkey = new PublicKey(outboxItem!); + + const destination = { + address: new UniversalAddress(recipientAddress, 'hex'), + chain: toChain as 'Ethereum', + }; + + const from = await getAssociatedTokenAddress(new PublicKey(mMint), sender, true, TOKEN_2022_PROGRAM_ID); + const transferArgs = NTT.transferArgs(BigInt(amount), destination, false); + + ixs.push( + createApproveInstruction( + from, + ntt.pdas.sessionAuthority(sender, transferArgs), + sender, + BigInt(amount), + [], + TOKEN_2022_PROGRAM_ID, + ), + ); + + ixs.push( + await NTT.createTransferBurnInstruction( + ntt.program, + await ntt.getConfig(), + { + transferArgs, + payer: sender, + from, + fromAuthority: sender, + outboxItem: outboxItemPubkey, + }, + ntt.pdas, + ), + ); - throw new SimulationFailed({ - message: `Simulation failed: ${JSON.stringify(sim.err)}`, - logs, - b64: b64, - }); + const whTransceiver = await ntt.getWormholeTransceiver(); + if (whTransceiver) { + ixs.push(await whTransceiver.createReleaseWormholeOutboundIx(sender, outboxItemPubkey, true)); } - logger.info('Swap simulation successful', { logs, quoteId, userPublicKey, b64 }); + const fee = await ntt.quoteDeliveryPrice(destination.chain, { queue: false, automatic: true }); + + ixs.push( + await ntt.quoter!.createRequestRelayInstruction( + sender, + outboxItemPubkey, + destination.chain, + Number(fee) / LAMPORTS_PER_SOL, + 0, + ), + ); + + // @ts-ignore // load LUT from NTT pda + const lut = (await ntt.program.account.lut.fetchNullable(ntt.pdas.lutAccount()))!.address; + + const { logs, b64, formattedInstructions } = await buildTransaction(userPublicKey, ixs, [lut]); res.send({ transaction: b64, simulationLogs: logs, + luts: [lut.toBase58()], + instructions: formattedInstructions, }); }, }); +async function buildTransaction(payer: string | PublicKey, ixs: TransactionInstruction[], luts: PublicKey[]) { + const addressLookupTableAccounts = await getAddressLookupTableAccounts(luts); + + const blockhash = (await connection.getLatestBlockhash({ commitment: 'finalized' })).blockhash; + const messageV0 = new TransactionMessage({ + payerKey: new PublicKey(payer), + recentBlockhash: blockhash, + instructions: ixs, + }).compileToV0Message(addressLookupTableAccounts); + + const transaction = new VersionedTransaction(messageV0); + + let sim: SimulatedTransactionResponse; + try { + sim = (await connection.simulateTransaction(transaction, { replaceRecentBlockhash: true })).value; + } catch (error) { + throw new SimulationFailed({ + message: `Simulation failed: ${error}`, + }); + } + + const logs = sim.logs || []; + const b64 = Buffer.from(transaction.serialize()).toString('base64'); + + if (sim.err) { + logger.error('Swap simulation failed', { logs, payer, b64 }); + + throw new SimulationFailed({ + message: `Simulation failed: ${JSON.stringify(sim.err)}`, + logs, + b64: b64, + }); + } + + const formattedInstructions = ixs.map((ix) => ({ + programId: ix.programId.toBase58(), + keys: ix.keys.map((key) => ({ + pubkey: key.pubkey.toBase58(), + isSigner: key.isSigner, + isWritable: key.isWritable, + })), + data: ix.data.toString('base64'), + })); + + return { logs, b64, formattedInstructions }; +} + function deserializeInstruction(instruction: Instruction) { return new TransactionInstruction({ programId: new PublicKey(instruction.programId), @@ -432,16 +556,40 @@ function convertRoutePlan(step: RoutePlanStep): RoutePlan { } function setWrapUnwrapQuote(quoteId: string, inputMint: string, outputMint: string, amount: string) { - const mProgram = 'MzeRokYa9o1ZikH6XHRiSS5nD8mNjZyHpLCBRTBSY4c'; quoteCache.set(quoteId, { extensionFrom: { mint: inputMint, - programId: extensionData.find((ext) => ext.mint === inputMint)?.programId ?? mProgram, + programId: extensionData.find((ext) => ext.mint === inputMint)?.programId ?? EARN, }, swapFacilityAmount: amount, extensionTo: { mint: outputMint, - programId: extensionData.find((ext) => ext.mint === outputMint)?.programId ?? mProgram, + programId: extensionData.find((ext) => ext.mint === outputMint)?.programId ?? EARN, }, }); } + +function NttManager() { + const connection = new Connection(process.env.SVM_RPC!, 'confirmed'); + const wormholeNetwork = process.env.SVM_RPC?.includes('devnet') ? 'Testnet' : 'Mainnet'; + const wh = new Wormhole(wormholeNetwork, [solana.Platform]); + const ctx = wh.getChain('Solana'); + + return new SolanaNtt( + wormholeNetwork, + 'Solana', + connection, + { + ...ctx.config.contracts, + ntt: { + token: mMint, + manager: 'mzp1q2j5Hr1QuLC3KFBCAUz5aUckT6qyuZKZ3WJnMmY', + transceiver: { + wormhole: 'mzp1q2j5Hr1QuLC3KFBCAUz5aUckT6qyuZKZ3WJnMmY', + }, + quoter: 'Nqd6XqA8LbsCuG8MLWWuP865NV6jR1MbXeKxD4HLKDJ', + }, + }, + '3.0.0', + ); +} diff --git a/services/repl/package.json b/services/repl/package.json new file mode 100644 index 00000000..f3e50458 --- /dev/null +++ b/services/repl/package.json @@ -0,0 +1,26 @@ +{ + "name": "repl", + "bin": "dist/cli.js", + "type": "module", + "scripts": { + "build": "tsc", + "dev": "tsc && node dist/cli.js" + }, + "files": [ + "dist" + ], + "dependencies": { + "@inkjs/ui": "^2.0.0", + "@m0-foundation/solana-m-api-sdk": "0.1.9", + "@solana/spl-token": "catalog:", + "@solana/web3.js": "catalog:", + "ink": "^4.4.1", + "react": "^18.3.1", + "react-query": "^3.39.3" + }, + "devDependencies": { + "@types/react": "^18.0.32", + "ts-node": "^10.9.1", + "typescript": "^5.0.3" + } +} diff --git a/services/repl/source/cli.tsx b/services/repl/source/cli.tsx new file mode 100644 index 00000000..d1f2c144 --- /dev/null +++ b/services/repl/source/cli.tsx @@ -0,0 +1,46 @@ +import React, { useState } from 'react'; +import { render } from 'ink'; +import { QueryClient, QueryClientProvider } from 'react-query'; +import { Text, Box } from 'ink'; +import Swap from './swap.js'; +import { Select } from '@inkjs/ui'; +import SwapAndBridgeFromSolana from './swap-and-bridge.js'; + +const queryClient = new QueryClient(); + +export default function App() { + const [selectedAction, setSelectedAction] = useState(); + + if (!selectedAction) + return ( + + Select an action: + ({ + label: token.name, + value: JSON.stringify(token), + })) ?? []), + ...(data?.extensions?.map((ext) => ({ + label: ext.name, + value: JSON.stringify(ext), + })) || []), + ]} + onChange={(value) => onChange(JSON.parse(value))} + /> + ); +} diff --git a/services/repl/source/useWallet.tsx b/services/repl/source/useWallet.tsx new file mode 100644 index 00000000..3ef07630 --- /dev/null +++ b/services/repl/source/useWallet.tsx @@ -0,0 +1,17 @@ +import { Connection, Keypair, VersionedTransaction } from '@solana/web3.js'; + +export const useWallet = () => { + const key = Keypair.fromSecretKey(Buffer.from(JSON.parse(process.env.PAYER_KEYPAIR!))); + const connection = new Connection(process.env.RPC_URL!, 'confirmed'); + + const signAndSendTransaction = async (transaction: VersionedTransaction) => { + transaction.sign([key]); + return await connection.sendTransaction(transaction); + }; + + return { + publicKey: key.publicKey, + signAndSendTransaction, + network: process.env.NETWORK! as 'mainnet' | 'devnet', + }; +}; diff --git a/services/repl/tsconfig.json b/services/repl/tsconfig.json new file mode 100644 index 00000000..2cbe8122 --- /dev/null +++ b/services/repl/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "target": "esnext", + "module": "node16", + "strict": false, + "esModuleInterop": true, + "resolveJsonModule": false, + "moduleResolution": "node16", + "jsx": "react-jsx", + "outDir": "dist", + "skipLibCheck": true + } +}