@ardrive/turbo-sdk 2.0.0 → 2.1.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/lib/cjs/cli/utils.js +1 -1
  2. package/lib/cjs/common/factory.js +1 -1
  3. package/lib/cjs/common/signer.js +4 -0
  4. package/lib/cjs/common/token/ario.js +11 -114
  5. package/lib/cjs/common/token/index.js +6 -0
  6. package/lib/cjs/common/token/solanaUsdc.js +29 -0
  7. package/lib/cjs/common/token/spl.js +186 -0
  8. package/lib/cjs/common/upload.js +1 -0
  9. package/lib/cjs/types.js +13 -1
  10. package/lib/cjs/utils/common.js +4 -0
  11. package/lib/cjs/version.js +1 -1
  12. package/lib/esm/cli/utils.js +1 -1
  13. package/lib/esm/common/factory.js +2 -2
  14. package/lib/esm/common/signer.js +4 -0
  15. package/lib/esm/common/token/ario.js +12 -112
  16. package/lib/esm/common/token/index.js +6 -0
  17. package/lib/esm/common/token/solanaUsdc.js +25 -0
  18. package/lib/esm/common/token/spl.js +179 -0
  19. package/lib/esm/common/upload.js +1 -0
  20. package/lib/esm/types.js +12 -0
  21. package/lib/esm/utils/common.js +4 -0
  22. package/lib/esm/version.js +1 -1
  23. package/lib/types/common/factory.d.ts.map +1 -1
  24. package/lib/types/common/signer.d.ts.map +1 -1
  25. package/lib/types/common/token/ario.d.ts +19 -22
  26. package/lib/types/common/token/ario.d.ts.map +1 -1
  27. package/lib/types/common/token/index.d.ts +2 -0
  28. package/lib/types/common/token/index.d.ts.map +1 -1
  29. package/lib/types/common/token/solanaUsdc.d.ts +40 -0
  30. package/lib/types/common/token/solanaUsdc.d.ts.map +1 -0
  31. package/lib/types/common/token/spl.d.ts +64 -0
  32. package/lib/types/common/token/spl.d.ts.map +1 -0
  33. package/lib/types/common/upload.d.ts.map +1 -1
  34. package/lib/types/types.d.ts +7 -1
  35. package/lib/types/types.d.ts.map +1 -1
  36. package/lib/types/utils/common.d.ts.map +1 -1
  37. package/lib/types/version.d.ts +1 -1
  38. package/lib/types/version.d.ts.map +1 -1
  39. package/package.json +2 -1
@@ -13,123 +13,23 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { createAssociatedTokenAccountIdempotentInstruction, createTransferCheckedInstruction, getAssociatedTokenAddressSync, } from '@solana/spl-token';
17
- import { Connection, PublicKey, Transaction, TransactionInstruction, } from '@solana/web3.js';
18
16
  import { BigNumber } from 'bignumber.js';
19
- import bs58 from 'bs58';
20
- import { defaultProdGatewayUrls, sleep } from '../../utils/common.js';
21
- import { Logger } from '../logger.js';
22
- import { memoProgramId } from './solana.js';
17
+ import { defaultProdGatewayUrls } from '../../utils/common.js';
18
+ import { SplToken } from './spl.js';
23
19
  const ARIO_SPL_MINT_ADDRESS = 'DcNnMuFxwhgV4WY1HVSaSEgr92bv2b1vUvEKiNxWqHdF';
24
20
  const DEVNET_ARIO_SPL_MINT_ADDRESS = '6vTw5CysRXQ4ybbHkDUiisHWVsBeMtUzYvJqs2iqHyaN';
25
21
  const ARIO_TOKEN_DECIMALS = 6;
26
- export class ARIOToken {
27
- constructor({ gatewayUrl = defaultProdGatewayUrls.solana, logger = Logger.default, pollingOptions = {
28
- maxAttempts: 10,
29
- pollingIntervalMs: 2_500,
30
- initialBackoffMs: 500,
31
- }, } = {}) {
32
- this.gatewayUrl = gatewayUrl;
33
- this.connection = new Connection(gatewayUrl, 'confirmed');
34
- this.pollingOptions = pollingOptions;
35
- this.logger = logger;
36
- if (gatewayUrl.includes('devnet')) {
37
- this.mintAddress = DEVNET_ARIO_SPL_MINT_ADDRESS;
38
- }
39
- else {
40
- this.mintAddress = ARIO_SPL_MINT_ADDRESS;
41
- }
42
- }
43
- async createAndSubmitTx({ target, signer, tokenAmount, turboCreditDestinationAddress, }) {
44
- const ownerPublicKey = new PublicKey(bs58.encode(Uint8Array.from(await signer.getPublicKey())));
45
- const recipient = new PublicKey(target);
46
- const mint = new PublicKey(this.mintAddress);
47
- const fromAta = getAssociatedTokenAddressSync(mint, ownerPublicKey);
48
- const toAta = getAssociatedTokenAddressSync(mint, recipient);
49
- const tx = new Transaction({
50
- feePayer: ownerPublicKey,
51
- ...(await this.connection.getLatestBlockhash()),
52
- });
53
- tx.add(createAssociatedTokenAccountIdempotentInstruction(ownerPublicKey, toAta, recipient, mint));
54
- tx.add(createTransferCheckedInstruction(fromAta, mint, toAta, ownerPublicKey, BigInt(new BigNumber(tokenAmount).toFixed(0)), ARIO_TOKEN_DECIMALS));
55
- if (turboCreditDestinationAddress !== undefined) {
56
- tx.add(new TransactionInstruction({
57
- programId: new PublicKey(memoProgramId),
58
- keys: [],
59
- data: Buffer.from('turboCreditDestinationAddress=' + turboCreditDestinationAddress),
60
- }));
61
- }
62
- const serializedTx = tx.serializeMessage();
63
- const signature = await signer.signData(Uint8Array.from(serializedTx));
64
- tx.addSignature(ownerPublicKey, Buffer.from(signature));
65
- const txId = bs58.encode(signature);
66
- await this.submitTx(tx, txId);
67
- this.logger.debug('Submitted ARIO SPL transfer transaction...', {
68
- id: txId,
69
- target,
70
- tokenAmount,
71
- fromAta: fromAta.toBase58(),
72
- toAta: toAta.toBase58(),
73
- mint: mint.toBase58(),
74
- });
75
- return { id: txId, target, reward: '0' };
76
- }
77
- async submitTx(tx, id) {
78
- this.logger.debug('Submitting ARIO fund transaction...', { id });
79
- await this.connection.sendRawTransaction(tx.serialize(), {
80
- maxRetries: this.pollingOptions.maxAttempts,
81
- });
82
- if (tx.recentBlockhash === undefined ||
83
- tx.lastValidBlockHeight === undefined) {
84
- throw new Error('Failed to submit Transaction -- missing blockhash or lastValidBlockHeight from transaction creation. Solana Gateway Url:' +
85
- this.gatewayUrl);
86
- }
87
- await this.connection.confirmTransaction({
88
- signature: id,
89
- blockhash: tx.recentBlockhash,
90
- lastValidBlockHeight: tx.lastValidBlockHeight,
91
- }, 'finalized');
92
- }
93
- async pollTxAvailability({ txId }) {
94
- const { maxAttempts, pollingIntervalMs, initialBackoffMs } = this.pollingOptions;
95
- this.logger.debug('Polling for ARIO SPL transaction...', {
96
- txId,
97
- pollingOptions: this.pollingOptions,
98
- gatewayUrl: this.gatewayUrl,
22
+ export class ARIOToken extends SplToken {
23
+ constructor({ gatewayUrl = defaultProdGatewayUrls.ario, ...config } = {}) {
24
+ super({
25
+ ...config,
26
+ gatewayUrl,
27
+ tokenName: 'ARIO',
28
+ decimals: ARIO_TOKEN_DECIMALS,
29
+ mintAddress: gatewayUrl.includes('devnet')
30
+ ? DEVNET_ARIO_SPL_MINT_ADDRESS
31
+ : ARIO_SPL_MINT_ADDRESS,
99
32
  });
100
- await sleep(initialBackoffMs);
101
- let attempts = 0;
102
- while (attempts < maxAttempts) {
103
- let status;
104
- attempts++;
105
- try {
106
- const statuses = await this.connection.getSignatureStatuses([txId], {
107
- searchTransactionHistory: true,
108
- });
109
- status = {
110
- context: statuses.context,
111
- value: statuses.value[0],
112
- };
113
- }
114
- catch (err) {
115
- this.logger.debug('Failed to poll ARIO SPL transaction...', { err });
116
- }
117
- if (status && status.value && status.value.err !== null) {
118
- throw new Error(`Transaction failed: ${status.value.err}`);
119
- }
120
- if (status && status.value && status.value.slot !== null) {
121
- this.logger.debug('Transaction found!', { txId, status });
122
- return;
123
- }
124
- this.logger.debug('ARIO SPL transaction not found, polling...', {
125
- txId,
126
- attempts,
127
- maxAttempts,
128
- pollingIntervalMs,
129
- });
130
- await sleep(pollingIntervalMs);
131
- }
132
- throw new Error('Transaction not found after polling, transaction id: ' + txId);
133
33
  }
134
34
  }
135
35
  export const mARIOToTokenAmount = (mARIO) => mARIO;
@@ -5,6 +5,7 @@ import { BaseEthToken } from './baseEth.js';
5
5
  import { ETHToTokenAmount, EthereumToken } from './ethereum.js';
6
6
  import { POLToTokenAmount, PolygonToken } from './polygon.js';
7
7
  import { SOLToTokenAmount, SolanaToken } from './solana.js';
8
+ import { SolanaUsdcToken } from './solanaUsdc.js';
8
9
  import { USDCToTokenAmount, USDCToken } from './usdc.js';
9
10
  export const defaultTokenMap = {
10
11
  arweave: (config) => new ArweaveToken(config),
@@ -17,6 +18,7 @@ export const defaultTokenMap = {
17
18
  usdc: (config) => new USDCToken({ network: 'ethereum', ...config }),
18
19
  'base-usdc': (config) => new USDCToken({ network: 'base', ...config }),
19
20
  'polygon-usdc': (config) => new USDCToken({ network: 'polygon', ...config }),
21
+ 'solana-usdc': (config) => new SolanaUsdcToken(config),
20
22
  };
21
23
  const ethExponent = 18;
22
24
  const usdcExponent = 6;
@@ -32,6 +34,7 @@ export const exponentMap = {
32
34
  usdc: usdcExponent,
33
35
  'base-usdc': usdcExponent,
34
36
  'polygon-usdc': usdcExponent,
37
+ 'solana-usdc': usdcExponent,
35
38
  };
36
39
  export const tokenToBaseMap = {
37
40
  arweave: (a) => ARToTokenAmount(a),
@@ -44,6 +47,7 @@ export const tokenToBaseMap = {
44
47
  usdc: (a) => USDCToTokenAmount(a),
45
48
  'base-usdc': (a) => USDCToTokenAmount(a),
46
49
  'polygon-usdc': (a) => USDCToTokenAmount(a),
50
+ 'solana-usdc': (a) => USDCToTokenAmount(a),
47
51
  };
48
52
  export function isTokenType(token) {
49
53
  return tokenTypes.includes(token);
@@ -54,3 +58,5 @@ export * from './solana.js';
54
58
  export * from './ethereum.js';
55
59
  export * from './baseEth.js';
56
60
  export * from './polygon.js';
61
+ export * from './spl.js';
62
+ export * from './solanaUsdc.js';
@@ -0,0 +1,25 @@
1
+ import { defaultProdGatewayUrls } from '../../utils/common.js';
2
+ import { SplToken } from './spl.js';
3
+ /** Circle's USDC mints on Solana. Both are 6-decimal SPL Token mints. */
4
+ export const SOLANA_USDC_MINT_ADDRESS = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v';
5
+ export const DEVNET_SOLANA_USDC_MINT_ADDRESS = '4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU';
6
+ const USDC_TOKEN_DECIMALS = 6;
7
+ /**
8
+ * USDC (SPL) on Solana. Signed with the ordinary Solana signer — the payer's
9
+ * USDC lives in an associated token account derived from the same keypair, so
10
+ * no extra wallet or approval step is involved.
11
+ */
12
+ export class SolanaUsdcToken extends SplToken {
13
+ constructor({ gatewayUrl = defaultProdGatewayUrls['solana-usdc'], mintAddress, ...config } = {}) {
14
+ super({
15
+ ...config,
16
+ gatewayUrl,
17
+ tokenName: 'USDC',
18
+ decimals: USDC_TOKEN_DECIMALS,
19
+ mintAddress: mintAddress ??
20
+ (gatewayUrl.includes('devnet')
21
+ ? DEVNET_SOLANA_USDC_MINT_ADDRESS
22
+ : SOLANA_USDC_MINT_ADDRESS),
23
+ });
24
+ }
25
+ }
@@ -0,0 +1,179 @@
1
+ /**
2
+ * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { createAssociatedTokenAccountIdempotentInstruction, createTransferCheckedInstruction, getAssociatedTokenAddressSync, } from '@solana/spl-token';
17
+ import { Connection, PublicKey, Transaction, TransactionInstruction, } from '@solana/web3.js';
18
+ import { BigNumber } from 'bignumber.js';
19
+ import bs58 from 'bs58';
20
+ import { isSolanaWalletAdapter, } from '../../types.js';
21
+ import { defaultProdGatewayUrls, sleep } from '../../utils/common.js';
22
+ import { Logger } from '../logger.js';
23
+ import { memoProgramId } from './solana.js';
24
+ /**
25
+ * Funding by an **SPL token transfer on Solana**: an idempotent
26
+ * create-associated-token-account, a `transferChecked` to the recipient's ATA,
27
+ * and an optional `turboCreditDestinationAddress=` memo when the credit should
28
+ * land on a different Turbo account than the payer.
29
+ *
30
+ * This is the generic shape of what `ARIOToken` has always done — ARIO is an SPL
31
+ * token — so a second SPL token (USDC) is a mint and a decimals value, not a
32
+ * second implementation. The payment service verifies both with one class too
33
+ * (`SolanaSplGateway`).
34
+ *
35
+ * Two constraints worth knowing before pointing this at a third token:
36
+ * - The associated token accounts are derived for the CLASSIC SPL Token
37
+ * program (Tokenkeg), which is what ARIO and USDC use. A Token-2022 mint
38
+ * derives a different ATA, so it would need its own program id threading
39
+ * through `getAssociatedTokenAddressSync`. It fails loudly on-chain rather
40
+ * than silently paying the wrong account.
41
+ * - `decimals` must match the mint's own. `transferChecked` carries the value
42
+ * and the chain rejects a mismatch, so a wrong value fails the transaction
43
+ * instead of transferring a wrong amount.
44
+ */
45
+ export class SplToken {
46
+ constructor({ mintAddress, decimals, tokenName = 'SPL', gatewayUrl = defaultProdGatewayUrls.solana, logger = Logger.default, pollingOptions = {
47
+ maxAttempts: 10,
48
+ pollingIntervalMs: 2_500,
49
+ initialBackoffMs: 500,
50
+ }, }) {
51
+ this.gatewayUrl = gatewayUrl;
52
+ this.connection = new Connection(gatewayUrl, 'confirmed');
53
+ this.pollingOptions = pollingOptions;
54
+ this.logger = logger;
55
+ this.mintAddress = mintAddress;
56
+ this.decimals = decimals;
57
+ this.tokenName = tokenName;
58
+ }
59
+ async createAndSubmitTx({ target, signer, tokenAmount, turboCreditDestinationAddress, }) {
60
+ const ownerPublicKey = new PublicKey(bs58.encode(Uint8Array.from(await signer.getPublicKey())));
61
+ const recipient = new PublicKey(target);
62
+ const mint = new PublicKey(this.mintAddress);
63
+ const fromAta = getAssociatedTokenAddressSync(mint, ownerPublicKey);
64
+ const toAta = getAssociatedTokenAddressSync(mint, recipient);
65
+ const tx = new Transaction({
66
+ feePayer: ownerPublicKey,
67
+ ...(await this.connection.getLatestBlockhash()),
68
+ });
69
+ tx.add(createAssociatedTokenAccountIdempotentInstruction(ownerPublicKey, toAta, recipient, mint));
70
+ tx.add(createTransferCheckedInstruction(fromAta, mint, toAta, ownerPublicKey, BigInt(new BigNumber(tokenAmount).toFixed(0)), this.decimals));
71
+ if (turboCreditDestinationAddress !== undefined) {
72
+ tx.add(new TransactionInstruction({
73
+ programId: new PublicKey(memoProgramId),
74
+ keys: [],
75
+ data: Buffer.from('turboCreditDestinationAddress=' + turboCreditDestinationAddress),
76
+ }));
77
+ }
78
+ const { signedTx, signature } = signer.walletAdapter !== undefined &&
79
+ isSolanaWalletAdapter(signer.walletAdapter)
80
+ ? await this.signWithWallet(tx, signer.walletAdapter)
81
+ : await this.signWithKey(tx, ownerPublicKey, signer);
82
+ const txId = bs58.encode(signature);
83
+ await this.submitTx(signedTx, txId);
84
+ this.logger.debug(`Submitted ${this.tokenName} SPL transfer transaction...`, {
85
+ id: txId,
86
+ target,
87
+ tokenAmount,
88
+ fromAta: fromAta.toBase58(),
89
+ toAta: toAta.toBase58(),
90
+ mint: mint.toBase58(),
91
+ });
92
+ return { id: txId, target, reward: '0' };
93
+ }
94
+ /** Sign the message bytes directly: a private-key signer holds the key. */
95
+ async signWithKey(tx, ownerPublicKey, signer) {
96
+ const signature = await signer.signData(Uint8Array.from(tx.serializeMessage()));
97
+ tx.addSignature(ownerPublicKey, Buffer.from(signature));
98
+ return { signedTx: tx, signature };
99
+ }
100
+ /**
101
+ * Have a browser wallet sign the transaction itself, as the SOL path does.
102
+ *
103
+ * A wallet signs through `signTransaction`, not `signMessage`: it refuses, or
104
+ * cannot display, a serialized transaction handed to it as a message. It may
105
+ * also add instructions of its own before signing (compute budget, guards),
106
+ * so the transaction submitted is the one it returns, never ours with its
107
+ * signature attached. Deserializing drops `lastValidBlockHeight`, so that is
108
+ * carried over for confirmation.
109
+ */
110
+ async signWithWallet(tx, walletAdapter) {
111
+ const signedTx = await walletAdapter.signTransaction(tx);
112
+ const signature = signedTx.signature;
113
+ if (signature === null) {
114
+ throw new Error(`Wallet returned an unsigned ${this.tokenName} transfer transaction`);
115
+ }
116
+ signedTx.recentBlockhash ??= tx.recentBlockhash;
117
+ signedTx.lastValidBlockHeight ??= tx.lastValidBlockHeight;
118
+ return { signedTx, signature: Uint8Array.from(signature) };
119
+ }
120
+ async submitTx(tx, id) {
121
+ this.logger.debug(`Submitting ${this.tokenName} fund transaction...`, {
122
+ id,
123
+ });
124
+ await this.connection.sendRawTransaction(tx.serialize(), {
125
+ maxRetries: this.pollingOptions.maxAttempts,
126
+ });
127
+ if (tx.recentBlockhash === undefined ||
128
+ tx.lastValidBlockHeight === undefined) {
129
+ throw new Error('Failed to submit Transaction -- missing blockhash or lastValidBlockHeight from transaction creation. Solana Gateway Url:' +
130
+ this.gatewayUrl);
131
+ }
132
+ await this.connection.confirmTransaction({
133
+ signature: id,
134
+ blockhash: tx.recentBlockhash,
135
+ lastValidBlockHeight: tx.lastValidBlockHeight,
136
+ }, 'finalized');
137
+ }
138
+ async pollTxAvailability({ txId }) {
139
+ const { maxAttempts, pollingIntervalMs, initialBackoffMs } = this.pollingOptions;
140
+ this.logger.debug(`Polling for ${this.tokenName} SPL transaction...`, {
141
+ txId,
142
+ pollingOptions: this.pollingOptions,
143
+ gatewayUrl: this.gatewayUrl,
144
+ });
145
+ await sleep(initialBackoffMs);
146
+ let attempts = 0;
147
+ while (attempts < maxAttempts) {
148
+ let status;
149
+ attempts++;
150
+ try {
151
+ const statuses = await this.connection.getSignatureStatuses([txId], {
152
+ searchTransactionHistory: true,
153
+ });
154
+ status = {
155
+ context: statuses.context,
156
+ value: statuses.value[0],
157
+ };
158
+ }
159
+ catch (err) {
160
+ this.logger.debug(`Failed to poll ${this.tokenName} SPL transaction...`, { err });
161
+ }
162
+ if (status && status.value && status.value.err !== null) {
163
+ throw new Error(`Transaction failed: ${status.value.err}`);
164
+ }
165
+ if (status && status.value && status.value.slot !== null) {
166
+ this.logger.debug('Transaction found!', { txId, status });
167
+ return;
168
+ }
169
+ this.logger.debug(`${this.tokenName} SPL transaction not found, polling...`, {
170
+ txId,
171
+ attempts,
172
+ maxAttempts,
173
+ pollingIntervalMs,
174
+ });
175
+ await sleep(pollingIntervalMs);
176
+ }
177
+ throw new Error('Transaction not found after polling, transaction id: ' + txId);
178
+ }
179
+ }
@@ -245,6 +245,7 @@ export class TurboAuthenticatedBaseUploadService extends TurboUnauthenticatedUpl
245
245
  'solana',
246
246
  'base-eth',
247
247
  'base-usdc',
248
+ 'solana-usdc',
248
249
  ];
249
250
  this.signer = signer;
250
251
  this.paymentService = paymentService;
package/lib/esm/types.js CHANGED
@@ -25,7 +25,19 @@ export const tokenTypes = [
25
25
  'usdc',
26
26
  'base-usdc',
27
27
  'polygon-usdc',
28
+ // USDC (SPL) on Solana — signed with the Solana signer, not an EVM one.
29
+ 'solana-usdc',
28
30
  ];
31
+ /**
32
+ * Tokens paid from a Solana wallet: SOL natively, and ARIO and USDC as SPL
33
+ * transfers signed by the same ed25519 key. A private key for any of these
34
+ * builds a Solana signer, so a Solana wallet adapter must as well.
35
+ */
36
+ export const supportedSolanaSignerTokens = new Set([
37
+ 'solana',
38
+ 'ario',
39
+ 'solana-usdc',
40
+ ]);
29
41
  export const supportedEvmSignerTokens = new Set([
30
42
  'ethereum',
31
43
  'base-eth',
@@ -38,6 +38,7 @@ export const tokenToDevGatewayMap = {
38
38
  usdc: ethTestnetRpc,
39
39
  'base-usdc': baseTestnetRpc,
40
40
  'polygon-usdc': polygonTestnetRpc,
41
+ 'solana-usdc': 'https://api.devnet.solana.com',
41
42
  };
42
43
  export const defaultProdGatewayUrls = {
43
44
  arweave: 'https://turbo-gateway.com',
@@ -50,6 +51,7 @@ export const defaultProdGatewayUrls = {
50
51
  usdc: 'https://cloudflare-eth.com/',
51
52
  'base-usdc': baseMainnetRpc,
52
53
  'polygon-usdc': 'https://polygon-rpc.com/',
54
+ 'solana-usdc': 'https://api.mainnet-beta.solana.com',
53
55
  };
54
56
  export function createTurboSigner({ signer: clientProvidedSigner, privateKey: clientProvidedPrivateKey, token = 'arweave', }) {
55
57
  if (clientProvidedSigner !== undefined) {
@@ -71,6 +73,7 @@ export function createTurboSigner({ signer: clientProvidedSigner, privateKey: cl
71
73
  switch (token) {
72
74
  case 'solana':
73
75
  case 'ario':
76
+ case 'solana-usdc':
74
77
  return new HexSolanaSigner(clientProvidedPrivateKey);
75
78
  case 'ethereum':
76
79
  case 'pol':
@@ -116,6 +119,7 @@ export function isValidUserAddress(address, type) {
116
119
  return isValidArweaveBase64URL(address);
117
120
  case 'ario':
118
121
  case 'solana':
122
+ case 'solana-usdc':
119
123
  return isValidSolanaAddress(address);
120
124
  case 'ethereum':
121
125
  case 'base-eth':
@@ -14,4 +14,4 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
17
- export const version = '2.0.0';
17
+ export const version = '2.1.0-alpha.2';
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/common/factory.ts"],"names":[],"mappings":"AAqBA,OAAO,EACL,oBAAoB,EAEpB,+BAA+B,EAC/B,4CAA4C,EAC5C,wCAAwC,EACxC,iCAAiC,EAKlC,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EACL,gCAAgC,EAEjC,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,YAAY,CAAC;AAGpB,8BAAsB,gBAAgB;IACpC,SAAS,CAAC,MAAM,CAAC,MAAM,SAAkB;IAGzC,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ;IAIlC,MAAM,CAAC,eAAe,CAAC,EACrB,oBAAyB,EACzB,mBAAwB,EACxB,KAAK,GACN,GAAE,iCAAsC;IAqBzC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,EAC3B,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,MAAM,EACN,KAAK,GACN,EAAE,oBAAoB,GAAG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AsCf,4BAA4B,CAGvC,KAAK,GAAE,MAAwC,EAM/C,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,yBAAyB,CAAC;IAexB,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;IAI/B,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC;IAOvD,gGAAgG;IACnF,eAAe,CAAC,EAC3B,MAAM,EACN,MAAM,EACN,UAAU,EACV,6BAA6B,GAC9B,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC;IAuF9B,QAAQ,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;CAgBnE;AAED;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAClC,eAAe,EAAE,cAAc,GAC9B,OAAO,CAAC,eAAe,CAAC,CAsC1B"}
@@ -1,26 +1,23 @@
1
- import { Connection } from '@solana/web3.js';
1
+ /**
2
+ * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
2
16
  import { BigNumber } from 'bignumber.js';
3
- import { AoProcessConfig, TokenConfig, TokenCreateTxParams, TokenPollingOptions, TokenTools, TurboLogger } from '../../types.js';
4
- export declare class ARIOToken implements TokenTools {
5
- protected logger: TurboLogger;
6
- protected connection: Connection;
7
- protected gatewayUrl: string;
8
- private pollingOptions;
9
- private mintAddress;
10
- constructor({ gatewayUrl, logger, pollingOptions, }?: {
11
- gatewayUrl?: string;
12
- logger?: TurboLogger;
13
- pollingOptions?: TokenPollingOptions;
14
- } & Partial<AoProcessConfig> & TokenConfig);
15
- createAndSubmitTx({ target, signer, tokenAmount, turboCreditDestinationAddress, }: TokenCreateTxParams): Promise<{
16
- id: string;
17
- target: string;
18
- reward: string;
19
- }>;
20
- private submitTx;
21
- pollTxAvailability({ txId }: {
22
- txId: string;
23
- }): Promise<void>;
17
+ import { AoProcessConfig, TokenConfig } from '../../types.js';
18
+ import { SplToken } from './spl.js';
19
+ export declare class ARIOToken extends SplToken {
20
+ constructor({ gatewayUrl, ...config }?: Partial<AoProcessConfig> & TokenConfig);
24
21
  }
25
22
  export declare const mARIOToTokenAmount: (mARIO: BigNumber.Value) => BigNumber.Value;
26
23
  export declare const ARIOToTokenAmount: (ario: BigNumber.Value) => string;
@@ -1 +1 @@
1
- {"version":3,"file":"ario.d.ts","sourceRoot":"","sources":["../../../../src/common/token/ario.ts"],"names":[],"mappings":"AAoBA,OAAO,EACL,UAAU,EAMX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EACL,eAAe,EACf,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EACnB,UAAU,EACV,WAAW,EACZ,MAAM,gBAAgB,CAAC;AAUxB,qBAAa,SAAU,YAAW,UAAU;IAC1C,SAAS,CAAC,MAAM,EAAE,WAAW,CAAC;IAE9B,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC;IACjC,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;IAC7B,OAAO,CAAC,cAAc,CAAsB;IAC5C,OAAO,CAAC,WAAW,CAAS;gBAEhB,EACV,UAA0C,EAC1C,MAAuB,EACvB,cAIC,GACF,GAAE;QACD,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,WAAW,CAAC;QACrB,cAAc,CAAC,EAAE,mBAAmB,CAAC;KACtC,GAAG,OAAO,CAAC,eAAe,CAAC,GAC1B,WAAgB;IAcL,iBAAiB,CAAC,EAC7B,MAAM,EACN,MAAM,EACN,WAAW,EACX,6BAA6B,GAC9B,EAAE,mBAAmB,GAAG,OAAO,CAAC;QAC/B,EAAE,EAAE,MAAM,CAAC;QACX,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;YAkEY,QAAQ;IA2BT,kBAAkB,CAAC,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAqD3E;AAED,eAAO,MAAM,kBAAkB,UAAW,SAAS,CAAC,KAAK,oBAAU,CAAC;AACpE,eAAO,MAAM,iBAAiB,SAAU,SAAS,CAAC,KAAK,WACb,CAAC"}
1
+ {"version":3,"file":"ario.d.ts","sourceRoot":"","sources":["../../../../src/common/token/ario.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAOpC,qBAAa,SAAU,SAAQ,QAAQ;gBACzB,EACV,UAAwC,EACxC,GAAG,MAAM,EACV,GAAE,OAAO,CAAC,eAAe,CAAC,GAAG,WAAgB;CAW/C;AAED,eAAO,MAAM,kBAAkB,UAAW,SAAS,CAAC,KAAK,oBAAU,CAAC;AACpE,eAAO,MAAM,iBAAiB,SAAU,SAAS,CAAC,KAAK,WACb,CAAC"}
@@ -25,4 +25,6 @@ export * from './solana.js';
25
25
  export * from './ethereum.js';
26
26
  export * from './baseEth.js';
27
27
  export * from './polygon.js';
28
+ export * from './spl.js';
29
+ export * from './solanaUsdc.js';
28
30
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/common/token/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,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cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { TokenConfig } from '../../types.js';
17
+ import { SplToken } from './spl.js';
18
+ /** Circle's USDC mints on Solana. Both are 6-decimal SPL Token mints. */
19
+ export declare const SOLANA_USDC_MINT_ADDRESS = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
20
+ export declare const DEVNET_SOLANA_USDC_MINT_ADDRESS = "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU";
21
+ export type SolanaUsdcTokenConfig = TokenConfig & {
22
+ /**
23
+ * The USDC mint to pay with. PREFER SETTING THIS EXPLICITLY when `gatewayUrl`
24
+ * is a custom RPC: the default below infers the cluster from the URL, which
25
+ * is only a heuristic — a paid devnet endpoint whose hostname doesn't contain
26
+ * "devnet" would otherwise select the MAINNET mint, and the payment would
27
+ * never be credited (it can't move mainnet value from a devnet wallet, but it
28
+ * does fail confusingly).
29
+ */
30
+ mintAddress?: string;
31
+ };
32
+ /**
33
+ * USDC (SPL) on Solana. Signed with the ordinary Solana signer — the payer's
34
+ * USDC lives in an associated token account derived from the same keypair, so
35
+ * no extra wallet or approval step is involved.
36
+ */
37
+ export declare class SolanaUsdcToken extends SplToken {
38
+ constructor({ gatewayUrl, mintAddress, ...config }?: SolanaUsdcTokenConfig);
39
+ }
40
+ //# sourceMappingURL=solanaUsdc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solanaUsdc.d.ts","sourceRoot":"","sources":["../../../../src/common/token/solanaUsdc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,yEAAyE;AACzE,eAAO,MAAM,wBAAwB,iDACW,CAAC;AACjD,eAAO,MAAM,+BAA+B,iDACI,CAAC;AAGjD,MAAM,MAAM,qBAAqB,GAAG,WAAW,GAAG;IAChD;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,QAAQ;gBAC/B,EACV,UAAkD,EAClD,WAAW,EACX,GAAG,MAAM,EACV,GAAE,qBAA0B;CAa9B"}
@@ -0,0 +1,64 @@
1
+ import { Connection } from '@solana/web3.js';
2
+ import { AoProcessConfig, TokenConfig, TokenCreateTxParams, TokenPollingOptions, TokenTools, TurboLogger } from '../../types.js';
3
+ /**
4
+ * Funding by an **SPL token transfer on Solana**: an idempotent
5
+ * create-associated-token-account, a `transferChecked` to the recipient's ATA,
6
+ * and an optional `turboCreditDestinationAddress=` memo when the credit should
7
+ * land on a different Turbo account than the payer.
8
+ *
9
+ * This is the generic shape of what `ARIOToken` has always done — ARIO is an SPL
10
+ * token — so a second SPL token (USDC) is a mint and a decimals value, not a
11
+ * second implementation. The payment service verifies both with one class too
12
+ * (`SolanaSplGateway`).
13
+ *
14
+ * Two constraints worth knowing before pointing this at a third token:
15
+ * - The associated token accounts are derived for the CLASSIC SPL Token
16
+ * program (Tokenkeg), which is what ARIO and USDC use. A Token-2022 mint
17
+ * derives a different ATA, so it would need its own program id threading
18
+ * through `getAssociatedTokenAddressSync`. It fails loudly on-chain rather
19
+ * than silently paying the wrong account.
20
+ * - `decimals` must match the mint's own. `transferChecked` carries the value
21
+ * and the chain rejects a mismatch, so a wrong value fails the transaction
22
+ * instead of transferring a wrong amount.
23
+ */
24
+ export declare class SplToken implements TokenTools {
25
+ protected logger: TurboLogger;
26
+ protected connection: Connection;
27
+ protected gatewayUrl: string;
28
+ protected pollingOptions: TokenPollingOptions;
29
+ protected mintAddress: string;
30
+ protected decimals: number;
31
+ /** Token name, used in log messages only. */
32
+ protected tokenName: string;
33
+ constructor({ mintAddress, decimals, tokenName, gatewayUrl, logger, pollingOptions, }: {
34
+ mintAddress: string;
35
+ decimals: number;
36
+ tokenName?: string;
37
+ gatewayUrl?: string;
38
+ logger?: TurboLogger;
39
+ pollingOptions?: TokenPollingOptions;
40
+ } & Partial<AoProcessConfig> & TokenConfig);
41
+ createAndSubmitTx({ target, signer, tokenAmount, turboCreditDestinationAddress, }: TokenCreateTxParams): Promise<{
42
+ id: string;
43
+ target: string;
44
+ reward: string;
45
+ }>;
46
+ /** Sign the message bytes directly: a private-key signer holds the key. */
47
+ private signWithKey;
48
+ /**
49
+ * Have a browser wallet sign the transaction itself, as the SOL path does.
50
+ *
51
+ * A wallet signs through `signTransaction`, not `signMessage`: it refuses, or
52
+ * cannot display, a serialized transaction handed to it as a message. It may
53
+ * also add instructions of its own before signing (compute budget, guards),
54
+ * so the transaction submitted is the one it returns, never ours with its
55
+ * signature attached. Deserializing drops `lastValidBlockHeight`, so that is
56
+ * carried over for confirmation.
57
+ */
58
+ private signWithWallet;
59
+ private submitTx;
60
+ pollTxAvailability({ txId }: {
61
+ txId: string;
62
+ }): Promise<void>;
63
+ }
64
+ //# sourceMappingURL=spl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spl.d.ts","sourceRoot":"","sources":["../../../../src/common/token/spl.ts"],"names":[],"mappings":"AAoBA,OAAO,EACL,UAAU,EAMX,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EACL,eAAe,EAEf,WAAW,EACX,mBAAmB,EACnB,mBAAmB,EACnB,UA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