@ardrive/turbo-sdk 1.23.5 → 1.24.0

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 (54) hide show
  1. package/README.md +21 -0
  2. package/bundles/web.bundle.min.js +71400 -57737
  3. package/lib/cjs/cli/commands/cryptoFund.js +1 -1
  4. package/lib/cjs/cli/constants.js +18 -9
  5. package/lib/cjs/cli/options.js +10 -0
  6. package/lib/cjs/cli/utils.js +20 -10
  7. package/lib/cjs/common/factory.js +3 -1
  8. package/lib/cjs/common/signer.js +1 -0
  9. package/lib/cjs/common/token/ario.js +116 -0
  10. package/lib/cjs/common/token/index.js +5 -0
  11. package/lib/cjs/node/factory.js +3 -1
  12. package/lib/cjs/types.js +1 -0
  13. package/lib/cjs/utils/common.js +34 -0
  14. package/lib/cjs/version.js +1 -1
  15. package/lib/cjs/web/factory.js +3 -1
  16. package/lib/esm/cli/commands/cryptoFund.js +1 -1
  17. package/lib/esm/cli/constants.js +17 -9
  18. package/lib/esm/cli/options.js +10 -0
  19. package/lib/esm/cli/utils.js +19 -9
  20. package/lib/esm/common/factory.js +3 -1
  21. package/lib/esm/common/signer.js +1 -0
  22. package/lib/esm/common/token/ario.js +110 -0
  23. package/lib/esm/common/token/index.js +5 -0
  24. package/lib/esm/node/factory.js +3 -1
  25. package/lib/esm/types.js +1 -0
  26. package/lib/esm/utils/common.js +33 -0
  27. package/lib/esm/version.js +1 -1
  28. package/lib/esm/web/factory.js +3 -1
  29. package/lib/types/cli/constants.d.ts +1 -17
  30. package/lib/types/cli/constants.d.ts.map +1 -1
  31. package/lib/types/cli/options.d.ts +10 -0
  32. package/lib/types/cli/options.d.ts.map +1 -1
  33. package/lib/types/cli/types.d.ts +2 -0
  34. package/lib/types/cli/types.d.ts.map +1 -1
  35. package/lib/types/cli/utils.d.ts.map +1 -1
  36. package/lib/types/common/factory.d.ts +1 -1
  37. package/lib/types/common/factory.d.ts.map +1 -1
  38. package/lib/types/common/signer.d.ts +2 -2
  39. package/lib/types/common/signer.d.ts.map +1 -1
  40. package/lib/types/common/token/ario.d.ts +23 -0
  41. package/lib/types/common/token/ario.d.ts.map +1 -0
  42. package/lib/types/common/token/index.d.ts +1 -0
  43. package/lib/types/common/token/index.d.ts.map +1 -1
  44. package/lib/types/node/factory.d.ts +1 -1
  45. package/lib/types/node/factory.d.ts.map +1 -1
  46. package/lib/types/types.d.ts +11 -3
  47. package/lib/types/types.d.ts.map +1 -1
  48. package/lib/types/utils/common.d.ts +14 -0
  49. package/lib/types/utils/common.d.ts.map +1 -1
  50. package/lib/types/version.d.ts +1 -1
  51. package/lib/types/version.d.ts.map +1 -1
  52. package/lib/types/web/factory.d.ts +1 -1
  53. package/lib/types/web/factory.d.ts.map +1 -1
  54. package/package.json +2 -1
@@ -47,7 +47,7 @@ async function cryptoFund(options) {
47
47
  const { confirm } = await (0, prompts_1.default)({
48
48
  type: 'confirm',
49
49
  name: 'confirm',
50
- message: `\nTransaction details:\n\n Amount: ${value} ${token}\n Target: ${targetWallet}\n Credits received: ${credits}\n Credit recipient: ${await turbo.signer.getNativeAddress()}\n Network fees: (Gas fees apply)\n\nThis payment is non-refundable. Proceed with transaction?`,
50
+ message: `\nTransaction details:\n\n Amount: ${value} ${token}\n Target: ${targetWallet}\n Est Credits to receive: ${credits}\n Credit recipient: ${await turbo.signer.getNativeAddress()}\n Note: Network Dependent Gas Fees May Apply\n\nThis payment is non-refundable. Proceed with transaction?`,
51
51
  initial: true,
52
52
  });
53
53
  if (!confirm) {
@@ -1,6 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.defaultProdGatewayUrls = exports.wincPerCredit = exports.turboCliTags = void 0;
4
+ /**
5
+ * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
4
19
  const version_js_1 = require("../version.js");
5
20
  exports.turboCliTags = [
6
21
  { name: 'App-Name', value: 'Turbo-CLI' },
@@ -8,12 +23,6 @@ exports.turboCliTags = [
8
23
  { name: 'App-Platform', value: process?.platform },
9
24
  ];
10
25
  exports.wincPerCredit = 1_000_000_000_000;
11
- exports.defaultProdGatewayUrls = {
12
- arweave: 'https://arweave.net',
13
- solana: 'https://api.mainnet-beta.solana.com',
14
- ethereum: 'https://cloudflare-eth.com/',
15
- 'base-eth': 'https://mainnet.base.org',
16
- kyve: 'https://api.kyve.network/',
17
- matic: 'https://polygon-rpc.com/',
18
- pol: 'https://polygon-rpc.com/',
19
- };
26
+ // Export from here for backwards compatibility
27
+ var common_js_1 = require("../utils/common.js");
28
+ Object.defineProperty(exports, "defaultProdGatewayUrls", { enumerable: true, get: function () { return common_js_1.defaultProdGatewayUrls; } });
@@ -76,6 +76,16 @@ exports.optionMap = {
76
76
  description: 'Set a custom payment service URL',
77
77
  default: undefined,
78
78
  },
79
+ processId: {
80
+ alias: '--process-id <processId>',
81
+ description: 'Set a custom target process ID for the action',
82
+ default: undefined,
83
+ },
84
+ cuUrl: {
85
+ alias: '--cu-url <cuUrl>',
86
+ description: 'Set a custom CU URL for the action',
87
+ default: undefined,
88
+ },
79
89
  dev: {
80
90
  alias: '--dev',
81
91
  description: 'Enable Turbo development endpoints',
@@ -36,6 +36,7 @@ exports.getTagsFromOptions = getTagsFromOptions;
36
36
  const bs58_1 = __importDefault(require("bs58"));
37
37
  const fs_1 = require("fs");
38
38
  const index_js_1 = require("../node/index.js");
39
+ const common_js_1 = require("../utils/common.js");
39
40
  const errors_js_1 = require("./errors.js");
40
41
  function exitWithErrorLog(error) {
41
42
  console.error(error instanceof Error ? error.message : error);
@@ -128,20 +129,13 @@ async function privateKeyFromOptions({ mnemonic, privateKey, walletFile, token,
128
129
  // TODO: Add prompts for selecting wallet type and secure input
129
130
  throw new errors_js_1.NoWalletProvidedError();
130
131
  }
131
- const tokenToDevGatewayMap = {
132
- arweave: 'https://arweave.net', // No arweave test net
133
- solana: 'https://api.devnet.solana.com',
134
- ethereum: 'https://ethereum-holesky-rpc.publicnode.com',
135
- 'base-eth': 'https://sepolia.base.org',
136
- kyve: 'https://api.korellia.kyve.network',
137
- matic: 'https://rpc-amoy.polygon.technology',
138
- pol: 'https://rpc-amoy.polygon.technology',
139
- };
140
132
  function configFromOptions(options) {
141
133
  const token = tokenFromOptions(options);
142
134
  let paymentUrl = undefined;
143
135
  let uploadUrl = undefined;
144
136
  let gatewayUrl = undefined;
137
+ let processId = undefined;
138
+ let cuUrl = undefined;
145
139
  if (options.local && options.dev) {
146
140
  throw new Error('Cannot use both --local and --dev flags');
147
141
  }
@@ -149,7 +143,11 @@ function configFromOptions(options) {
149
143
  // Use development endpoints
150
144
  paymentUrl = index_js_1.developmentTurboConfiguration.paymentServiceConfig.url;
151
145
  uploadUrl = index_js_1.developmentTurboConfiguration.uploadServiceConfig.url;
152
- gatewayUrl = tokenToDevGatewayMap[token];
146
+ gatewayUrl = common_js_1.tokenToDevGatewayMap[token];
147
+ if (options.token === 'ario') {
148
+ processId = common_js_1.tokenToDevAoConfigMap[token].processId;
149
+ cuUrl = common_js_1.tokenToDevAoConfigMap[token].cuUrl;
150
+ }
153
151
  }
154
152
  else if (options.local) {
155
153
  // Use local endpoints
@@ -161,6 +159,10 @@ function configFromOptions(options) {
161
159
  // Use default endpoints
162
160
  paymentUrl = index_js_1.defaultTurboConfiguration.paymentServiceConfig.url;
163
161
  uploadUrl = index_js_1.defaultTurboConfiguration.uploadServiceConfig.url;
162
+ if (options.token === 'ario') {
163
+ processId = common_js_1.defaultProdAoConfigs[token].processId;
164
+ cuUrl = common_js_1.defaultProdAoConfigs[token].cuUrl;
165
+ }
164
166
  }
165
167
  // Override gateway, payment, and upload service default endpoints if provided
166
168
  if (options.gateway !== undefined) {
@@ -172,11 +174,19 @@ function configFromOptions(options) {
172
174
  if (options.uploadUrl !== undefined) {
173
175
  uploadUrl = options.uploadUrl;
174
176
  }
177
+ if (options.cuUrl !== undefined) {
178
+ cuUrl = options.cuUrl;
179
+ }
180
+ if (options.processId !== undefined) {
181
+ processId = options.processId;
182
+ }
175
183
  const config = {
176
184
  paymentServiceConfig: { url: paymentUrl },
177
185
  uploadServiceConfig: { url: uploadUrl },
178
186
  gatewayUrl,
179
187
  token,
188
+ processId,
189
+ cuUrl,
180
190
  };
181
191
  return config;
182
192
  }
@@ -50,7 +50,7 @@ class TurboBaseFactory {
50
50
  paymentService,
51
51
  });
52
52
  }
53
- getAuthenticatedTurbo({ privateKey, signer: providedSigner, paymentServiceConfig = {}, uploadServiceConfig = {}, token, gatewayUrl, tokenMap, tokenTools, logger, walletAdapter, }) {
53
+ getAuthenticatedTurbo({ privateKey, signer: providedSigner, paymentServiceConfig = {}, uploadServiceConfig = {}, token, gatewayUrl, tokenMap, tokenTools, logger, walletAdapter, processId, cuUrl, }) {
54
54
  token = token === 'pol' ? 'matic' : token;
55
55
  if (!token) {
56
56
  if (providedSigner) {
@@ -85,6 +85,8 @@ class TurboBaseFactory {
85
85
  tokenTools = tokenMap.arweave;
86
86
  }
87
87
  tokenTools = index_js_1.defaultTokenMap[token]?.({
88
+ cuUrl,
89
+ processId,
88
90
  gatewayUrl,
89
91
  logger,
90
92
  });
@@ -58,6 +58,7 @@ class TurboDataItemAbstractSigner {
58
58
  value: (0, encoding_1.toBase64)(crypto_1.Secp256k1.compressPubkey(Uint8Array.from((0, base64_js_1.fromB64Url)(owner)))),
59
59
  }, 'kyve');
60
60
  case 'arweave':
61
+ case 'ario':
61
62
  return (0, base64_js_1.ownerToAddress)(owner);
62
63
  }
63
64
  }
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ARIOToTokenAmount = exports.mARIOToTokenAmount = exports.ARIOToken = void 0;
4
+ /**
5
+ * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ const arbundles_1 = require("@dha-team/arbundles");
20
+ const aoconnect_1 = require("@permaweb/aoconnect");
21
+ const bignumber_js_1 = require("bignumber.js");
22
+ const common_js_1 = require("../../utils/common.js");
23
+ const version_js_1 = require("../../version.js");
24
+ const logger_js_1 = require("../logger.js");
25
+ class ARIOToken {
26
+ constructor({ cuUrl = common_js_1.defaultProdAoConfigs.ario.cuUrl, logger = logger_js_1.TurboWinstonLogger.default, pollingOptions = {
27
+ initialBackoffMs: 500,
28
+ pollingIntervalMs: 0, // no polling for ARIO process
29
+ maxAttempts: 0, // no polling for ARIO process
30
+ }, processId = common_js_1.defaultProdAoConfigs.ario.processId, } = {}) {
31
+ this.ao = (0, aoconnect_1.connect)({
32
+ CU_URL: cuUrl,
33
+ });
34
+ this.processId = processId;
35
+ this.pollingOptions = pollingOptions;
36
+ this.logger = logger;
37
+ }
38
+ async createAndSubmitTx({ target, signer: { signer }, tokenAmount, }) {
39
+ const txId = await this.ao.message({
40
+ signer: createAoSigner(signer),
41
+ process: this.processId,
42
+ tags: [
43
+ {
44
+ name: 'Action',
45
+ value: 'Transfer',
46
+ },
47
+ {
48
+ name: 'Recipient',
49
+ value: target,
50
+ },
51
+ {
52
+ name: 'Quantity',
53
+ value: tokenAmount.toString(),
54
+ },
55
+ {
56
+ name: 'Turbo-SDK',
57
+ value: version_js_1.version,
58
+ },
59
+ ],
60
+ });
61
+ this.logger.debug('Submitted Transfer message to ARIO process...', {
62
+ id: txId,
63
+ target,
64
+ tokenAmount,
65
+ processId: this.processId,
66
+ });
67
+ return { id: txId, target, reward: '0' };
68
+ }
69
+ async pollForTxBeingAvailable() {
70
+ // AO finality should be instant -- but we'll wait initial backoff to
71
+ // provide infra some time to crank without reading the whole result
72
+ return (0, common_js_1.sleep)(this.pollingOptions.initialBackoffMs);
73
+ }
74
+ }
75
+ exports.ARIOToken = ARIOToken;
76
+ const mARIOToTokenAmount = (mARIO) => mARIO;
77
+ exports.mARIOToTokenAmount = mARIOToTokenAmount;
78
+ const ARIOToTokenAmount = (ario) => new bignumber_js_1.BigNumber(ario).times(1e6).valueOf();
79
+ exports.ARIOToTokenAmount = ARIOToTokenAmount;
80
+ function createAoSigner(signer) {
81
+ if (!('publicKey' in signer)) {
82
+ return (0, aoconnect_1.createDataItemSigner)(signer);
83
+ }
84
+ const aoSigner = async ({ data, tags, target, anchor }) => {
85
+ // ensure appropriate permissions are granted with injected signers.
86
+ if (signer.publicKey === undefined &&
87
+ 'setPublicKey' in signer &&
88
+ typeof signer.setPublicKey === 'function') {
89
+ await signer.setPublicKey();
90
+ }
91
+ if (signer instanceof arbundles_1.ArconnectSigner) {
92
+ // Sign using Arconnect signDataItem API
93
+ const signedDataItem = await signer['signer'].signDataItem({
94
+ data,
95
+ tags,
96
+ target,
97
+ anchor,
98
+ });
99
+ const dataItem = new arbundles_1.DataItem(Buffer.from(signedDataItem));
100
+ return {
101
+ id: dataItem.id,
102
+ raw: dataItem.getRaw(),
103
+ };
104
+ }
105
+ const dataItem = (0, arbundles_1.createData)(data ?? '', signer, { tags, target, anchor });
106
+ await dataItem.sign(signer);
107
+ const signedData = {
108
+ id: dataItem.id,
109
+ raw: dataItem.getRaw(),
110
+ };
111
+ return signedData;
112
+ };
113
+ // eslint-disable-next-line
114
+ // @ts-ignore Buffer vs ArrayBuffer type mismatch
115
+ return aoSigner;
116
+ }
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.tokenToBaseMap = exports.exponentMap = exports.defaultTokenMap = void 0;
18
18
  exports.isTokenType = isTokenType;
19
19
  const types_js_1 = require("../../types.js");
20
+ const ario_js_1 = require("./ario.js");
20
21
  const arweave_js_1 = require("./arweave.js");
21
22
  const baseEth_js_1 = require("./baseEth.js");
22
23
  const ethereum_js_1 = require("./ethereum.js");
@@ -25,6 +26,7 @@ const polygon_js_1 = require("./polygon.js");
25
26
  const solana_js_1 = require("./solana.js");
26
27
  exports.defaultTokenMap = {
27
28
  arweave: (config) => new arweave_js_1.ArweaveToken(config),
29
+ ario: (config) => new ario_js_1.ARIOToken(config),
28
30
  solana: (config) => new solana_js_1.SolanaToken(config),
29
31
  ethereum: (config) => new ethereum_js_1.EthereumToken(config),
30
32
  'base-eth': (config) => new baseEth_js_1.BaseEthToken(config),
@@ -35,6 +37,7 @@ exports.defaultTokenMap = {
35
37
  const ethExponent = 18;
36
38
  exports.exponentMap = {
37
39
  arweave: 12,
40
+ ario: 6,
38
41
  solana: 9,
39
42
  ethereum: ethExponent,
40
43
  'base-eth': ethExponent,
@@ -44,6 +47,7 @@ exports.exponentMap = {
44
47
  };
45
48
  exports.tokenToBaseMap = {
46
49
  arweave: (a) => (0, arweave_js_1.ARToTokenAmount)(a),
50
+ ario: (a) => (0, ario_js_1.ARIOToTokenAmount)(a),
47
51
  solana: (a) => (0, solana_js_1.SOLToTokenAmount)(a),
48
52
  ethereum: (a) => (0, ethereum_js_1.ETHToTokenAmount)(a),
49
53
  'base-eth': (a) => (0, ethereum_js_1.ETHToTokenAmount)(a),
@@ -55,6 +59,7 @@ function isTokenType(token) {
55
59
  return types_js_1.tokenTypes.includes(token);
56
60
  }
57
61
  __exportStar(require("./arweave.js"), exports);
62
+ __exportStar(require("./ario.js"), exports);
58
63
  __exportStar(require("./solana.js"), exports);
59
64
  __exportStar(require("./ethereum.js"), exports);
60
65
  __exportStar(require("./baseEth.js"), exports);
@@ -37,7 +37,7 @@ class TurboFactory extends factory_js_1.TurboBaseFactory {
37
37
  // Import the TurboAuthenticatedUploadService class from the node upload module
38
38
  return new upload_js_1.TurboAuthenticatedUploadService(config);
39
39
  }
40
- static authenticated({ privateKey, signer: providedSigner, paymentServiceConfig = {}, uploadServiceConfig = {}, token, tokenMap, gatewayUrl, tokenTools, walletAdapter, }) {
40
+ static authenticated({ privateKey, signer: providedSigner, paymentServiceConfig = {}, uploadServiceConfig = {}, token, tokenMap, gatewayUrl, tokenTools, walletAdapter, cuUrl, processId, }) {
41
41
  return new TurboFactory().getAuthenticatedTurbo({
42
42
  privateKey,
43
43
  signer: providedSigner,
@@ -48,6 +48,8 @@ class TurboFactory extends factory_js_1.TurboBaseFactory {
48
48
  gatewayUrl,
49
49
  tokenTools,
50
50
  walletAdapter,
51
+ processId,
52
+ cuUrl,
51
53
  logger: this.logger,
52
54
  });
53
55
  }
package/lib/cjs/types.js CHANGED
@@ -23,6 +23,7 @@ function isCurrency(currency) {
23
23
  }
24
24
  exports.tokenTypes = [
25
25
  'arweave',
26
+ 'ario',
26
27
  'solana',
27
28
  'ethereum',
28
29
  'kyve',
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultProdAoConfigs = exports.defaultProdGatewayUrls = exports.tokenToDevAoConfigMap = exports.tokenToDevGatewayMap = void 0;
3
4
  exports.sleep = sleep;
4
5
  exports.isWeb = isWeb;
5
6
  exports.createTurboSigner = createTurboSigner;
@@ -31,6 +32,38 @@ function sleep(ms) {
31
32
  function isWeb() {
32
33
  return typeof window !== 'undefined';
33
34
  }
35
+ exports.tokenToDevGatewayMap = {
36
+ arweave: 'https://arweave.net', // No arweave test net
37
+ ario: 'https://arweave.net', // No arweave test net
38
+ solana: 'https://api.devnet.solana.com',
39
+ ethereum: 'https://ethereum-holesky-rpc.publicnode.com',
40
+ 'base-eth': 'https://sepolia.base.org',
41
+ kyve: 'https://api.korellia.kyve.network',
42
+ matic: 'https://rpc-amoy.polygon.technology',
43
+ pol: 'https://rpc-amoy.polygon.technology',
44
+ };
45
+ exports.tokenToDevAoConfigMap = {
46
+ ario: {
47
+ processId: 'agYcCFJtrMG6cqMuZfskIkFTGvUPddICmtQSBIoPdiA',
48
+ cuUrl: 'https://cu.ardrive.io',
49
+ },
50
+ };
51
+ exports.defaultProdGatewayUrls = {
52
+ arweave: 'https://arweave.net',
53
+ ario: 'https://arweave.net',
54
+ solana: 'https://api.mainnet-beta.solana.com',
55
+ ethereum: 'https://cloudflare-eth.com/',
56
+ 'base-eth': 'https://mainnet.base.org',
57
+ kyve: 'https://api.kyve.network/',
58
+ matic: 'https://polygon-rpc.com/',
59
+ pol: 'https://polygon-rpc.com/',
60
+ };
61
+ exports.defaultProdAoConfigs = {
62
+ ario: {
63
+ processId: 'qNvAoz0TgcH7DMg8BCVn8jF32QH5L6T29VjHxhHqqGE',
64
+ cuUrl: 'https://cu.ardrive.io',
65
+ },
66
+ };
34
67
  function createTurboSigner({ signer: clientProvidedSigner, privateKey: clientProvidedPrivateKey, token = 'arweave', }) {
35
68
  if (clientProvidedSigner !== undefined) {
36
69
  return clientProvidedSigner;
@@ -55,6 +88,7 @@ function createTurboSigner({ signer: clientProvidedSigner, privateKey: clientPro
55
88
  }
56
89
  return signerFromKyvePrivateKey(clientProvidedPrivateKey);
57
90
  case 'arweave':
91
+ case 'ario':
58
92
  if (!(0, types_js_1.isJWK)(clientProvidedPrivateKey)) {
59
93
  throw new Error('A JWK must be provided for ArweaveSigner.');
60
94
  }
@@ -17,4 +17,4 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.version = void 0;
19
19
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
20
- exports.version = '1.23.5';
20
+ exports.version = '1.24.0';
@@ -37,7 +37,7 @@ class TurboFactory extends factory_js_1.TurboBaseFactory {
37
37
  // Import the TurboAuthenticatedUploadService class from the web upload module
38
38
  return new upload_js_1.TurboAuthenticatedUploadService(config);
39
39
  }
40
- static authenticated({ privateKey, signer: providedSigner, paymentServiceConfig = {}, uploadServiceConfig = {}, token, gatewayUrl, tokenMap, tokenTools, walletAdapter, }) {
40
+ static authenticated({ privateKey, signer: providedSigner, paymentServiceConfig = {}, uploadServiceConfig = {}, token, gatewayUrl, tokenMap, tokenTools, walletAdapter, cuUrl, processId, }) {
41
41
  return new TurboFactory().getAuthenticatedTurbo({
42
42
  privateKey,
43
43
  signer: providedSigner,
@@ -49,6 +49,8 @@ class TurboFactory extends factory_js_1.TurboBaseFactory {
49
49
  tokenTools,
50
50
  logger: this.logger,
51
51
  walletAdapter,
52
+ cuUrl,
53
+ processId,
52
54
  });
53
55
  }
54
56
  }
@@ -41,7 +41,7 @@ export async function cryptoFund(options) {
41
41
  const { confirm } = await prompts({
42
42
  type: 'confirm',
43
43
  name: 'confirm',
44
- message: `\nTransaction details:\n\n Amount: ${value} ${token}\n Target: ${targetWallet}\n Credits received: ${credits}\n Credit recipient: ${await turbo.signer.getNativeAddress()}\n Network fees: (Gas fees apply)\n\nThis payment is non-refundable. Proceed with transaction?`,
44
+ message: `\nTransaction details:\n\n Amount: ${value} ${token}\n Target: ${targetWallet}\n Est Credits to receive: ${credits}\n Credit recipient: ${await turbo.signer.getNativeAddress()}\n Note: Network Dependent Gas Fees May Apply\n\nThis payment is non-refundable. Proceed with transaction?`,
45
45
  initial: true,
46
46
  });
47
47
  if (!confirm) {
@@ -1,3 +1,18 @@
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
+ */
1
16
  import { version } from '../version.js';
2
17
  export const turboCliTags = [
3
18
  { name: 'App-Name', value: 'Turbo-CLI' },
@@ -5,12 +20,5 @@ export const turboCliTags = [
5
20
  { name: 'App-Platform', value: process?.platform },
6
21
  ];
7
22
  export const wincPerCredit = 1_000_000_000_000;
8
- export const defaultProdGatewayUrls = {
9
- arweave: 'https://arweave.net',
10
- solana: 'https://api.mainnet-beta.solana.com',
11
- ethereum: 'https://cloudflare-eth.com/',
12
- 'base-eth': 'https://mainnet.base.org',
13
- kyve: 'https://api.kyve.network/',
14
- matic: 'https://polygon-rpc.com/',
15
- pol: 'https://polygon-rpc.com/',
16
- };
23
+ // Export from here for backwards compatibility
24
+ export { defaultProdGatewayUrls } from '../utils/common.js';
@@ -73,6 +73,16 @@ export const optionMap = {
73
73
  description: 'Set a custom payment service URL',
74
74
  default: undefined,
75
75
  },
76
+ processId: {
77
+ alias: '--process-id <processId>',
78
+ description: 'Set a custom target process ID for the action',
79
+ default: undefined,
80
+ },
81
+ cuUrl: {
82
+ alias: '--cu-url <cuUrl>',
83
+ description: 'Set a custom CU URL for the action',
84
+ default: undefined,
85
+ },
76
86
  dev: {
77
87
  alias: '--dev',
78
88
  description: 'Enable Turbo development endpoints',
@@ -16,6 +16,7 @@
16
16
  import bs58 from 'bs58';
17
17
  import { readFileSync, statSync } from 'fs';
18
18
  import { TurboFactory, defaultTurboConfiguration, developmentTurboConfiguration, isTokenType, privateKeyFromKyveMnemonic, } from '../node/index.js';
19
+ import { defaultProdAoConfigs, tokenToDevAoConfigMap, tokenToDevGatewayMap, } from '../utils/common.js';
19
20
  import { NoWalletProvidedError } from './errors.js';
20
21
  export function exitWithErrorLog(error) {
21
22
  console.error(error instanceof Error ? error.message : error);
@@ -108,20 +109,13 @@ export async function privateKeyFromOptions({ mnemonic, privateKey, walletFile,
108
109
  // TODO: Add prompts for selecting wallet type and secure input
109
110
  throw new NoWalletProvidedError();
110
111
  }
111
- const tokenToDevGatewayMap = {
112
- arweave: 'https://arweave.net', // No arweave test net
113
- solana: 'https://api.devnet.solana.com',
114
- ethereum: 'https://ethereum-holesky-rpc.publicnode.com',
115
- 'base-eth': 'https://sepolia.base.org',
116
- kyve: 'https://api.korellia.kyve.network',
117
- matic: 'https://rpc-amoy.polygon.technology',
118
- pol: 'https://rpc-amoy.polygon.technology',
119
- };
120
112
  export function configFromOptions(options) {
121
113
  const token = tokenFromOptions(options);
122
114
  let paymentUrl = undefined;
123
115
  let uploadUrl = undefined;
124
116
  let gatewayUrl = undefined;
117
+ let processId = undefined;
118
+ let cuUrl = undefined;
125
119
  if (options.local && options.dev) {
126
120
  throw new Error('Cannot use both --local and --dev flags');
127
121
  }
@@ -130,6 +124,10 @@ export function configFromOptions(options) {
130
124
  paymentUrl = developmentTurboConfiguration.paymentServiceConfig.url;
131
125
  uploadUrl = developmentTurboConfiguration.uploadServiceConfig.url;
132
126
  gatewayUrl = tokenToDevGatewayMap[token];
127
+ if (options.token === 'ario') {
128
+ processId = tokenToDevAoConfigMap[token].processId;
129
+ cuUrl = tokenToDevAoConfigMap[token].cuUrl;
130
+ }
133
131
  }
134
132
  else if (options.local) {
135
133
  // Use local endpoints
@@ -141,6 +139,10 @@ export function configFromOptions(options) {
141
139
  // Use default endpoints
142
140
  paymentUrl = defaultTurboConfiguration.paymentServiceConfig.url;
143
141
  uploadUrl = defaultTurboConfiguration.uploadServiceConfig.url;
142
+ if (options.token === 'ario') {
143
+ processId = defaultProdAoConfigs[token].processId;
144
+ cuUrl = defaultProdAoConfigs[token].cuUrl;
145
+ }
144
146
  }
145
147
  // Override gateway, payment, and upload service default endpoints if provided
146
148
  if (options.gateway !== undefined) {
@@ -152,11 +154,19 @@ export function configFromOptions(options) {
152
154
  if (options.uploadUrl !== undefined) {
153
155
  uploadUrl = options.uploadUrl;
154
156
  }
157
+ if (options.cuUrl !== undefined) {
158
+ cuUrl = options.cuUrl;
159
+ }
160
+ if (options.processId !== undefined) {
161
+ processId = options.processId;
162
+ }
155
163
  const config = {
156
164
  paymentServiceConfig: { url: paymentUrl },
157
165
  uploadServiceConfig: { url: uploadUrl },
158
166
  gatewayUrl,
159
167
  token,
168
+ processId,
169
+ cuUrl,
160
170
  };
161
171
  return config;
162
172
  }
@@ -47,7 +47,7 @@ export class TurboBaseFactory {
47
47
  paymentService,
48
48
  });
49
49
  }
50
- getAuthenticatedTurbo({ privateKey, signer: providedSigner, paymentServiceConfig = {}, uploadServiceConfig = {}, token, gatewayUrl, tokenMap, tokenTools, logger, walletAdapter, }) {
50
+ getAuthenticatedTurbo({ privateKey, signer: providedSigner, paymentServiceConfig = {}, uploadServiceConfig = {}, token, gatewayUrl, tokenMap, tokenTools, logger, walletAdapter, processId, cuUrl, }) {
51
51
  token = token === 'pol' ? 'matic' : token;
52
52
  if (!token) {
53
53
  if (providedSigner) {
@@ -82,6 +82,8 @@ export class TurboBaseFactory {
82
82
  tokenTools = tokenMap.arweave;
83
83
  }
84
84
  tokenTools = defaultTokenMap[token]?.({
85
+ cuUrl,
86
+ processId,
85
87
  gatewayUrl,
86
88
  logger,
87
89
  });
@@ -52,6 +52,7 @@ export class TurboDataItemAbstractSigner {
52
52
  value: toBase64(Secp256k1.compressPubkey(Uint8Array.from(fromB64Url(owner)))),
53
53
  }, 'kyve');
54
54
  case 'arweave':
55
+ case 'ario':
55
56
  return ownerToB64Address(owner);
56
57
  }
57
58
  }