@ardrive/turbo-sdk 1.31.0-alpha.3 → 1.31.1-alpha.1

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.
@@ -215,17 +215,17 @@ class ChunkedUploader {
215
215
  async finalizeUpload(uploadId, dataItemByteCount, paidBy, signal) {
216
216
  // Wait up to 1 minute per GiB of data for the upload to finalize
217
217
  const fileSizeInGiB = Math.ceil(this.toGiB(dataItemByteCount));
218
- const defaultMaxWaitTimeMins = fileSizeInGiB;
219
- const maxWaitTimeMs = this.maxFinalizeMs ?? defaultMaxWaitTimeMins * 60 * 1000;
218
+ const defaultMaxWaitTimeMins = fileSizeInGiB * 2.5;
219
+ const maxWaitTimeMs = this.maxFinalizeMs ?? Math.floor(defaultMaxWaitTimeMins * 60 * 1000);
220
220
  const minimumWaitPerStepMs =
221
221
  // Per step, files smaller than 100MB will wait 2 second,
222
222
  dataItemByteCount < 1024 * 1024 * 100
223
223
  ? 2000
224
- : // files smaller than 3 GiB will wait 3 seconds,
224
+ : // files smaller than 3 GiB will wait 4 seconds,
225
225
  dataItemByteCount < 1024 * 1024 * 1024 * 3
226
- ? 3000
227
- : // and larger files will wait 1 second per GiB with max of 10 seconds
228
- Math.max(1000 * fileSizeInGiB, 10000);
226
+ ? 4000
227
+ : // and larger files will wait 1.5 second per GiB with max of 15 seconds
228
+ Math.max(1500 * fileSizeInGiB, 15000);
229
229
  const paidByHeader = {};
230
230
  if (paidBy !== undefined) {
231
231
  paidByHeader['x-paid-by'] = Array.isArray(paidBy)
@@ -242,7 +242,7 @@ class ChunkedUploader {
242
242
  },
243
243
  signal,
244
244
  });
245
- this.logger.debug(`Confirming upload to Turbo with uploadId ${uploadId} for up to ${defaultMaxWaitTimeMins} minutes.`);
245
+ this.logger.debug(`Confirming upload to Turbo with uploadId ${uploadId} for up to ${maxWaitTimeMs / 1000 / 60} minutes.`);
246
246
  const startTime = Date.now();
247
247
  const cutoffTime = startTime + maxWaitTimeMs;
248
248
  let attempts = 0;
@@ -123,7 +123,8 @@ class TurboBaseFactory {
123
123
  }
124
124
  return new arbundles_1.HexInjectedSolanaSigner(walletAdapter);
125
125
  }
126
- if (token === 'ethereum') {
126
+ const ethTokens = new Set(['ethereum', 'base-eth']);
127
+ if (ethTokens.has(token)) {
127
128
  if (!(0, types_js_1.isEthereumWalletAdapter)(walletAdapter)) {
128
129
  throw new Error('Unsupported wallet adapter -- must implement getSigner');
129
130
  }
@@ -26,6 +26,9 @@ const amino_1 = require("@cosmjs/amino");
26
26
  const crypto_1 = require("@cosmjs/crypto");
27
27
  const encoding_1 = require("@cosmjs/encoding");
28
28
  const arbundles_1 = require("@dha-team/arbundles");
29
+ const bytes_1 = require("@ethersproject/bytes");
30
+ const signing_key_1 = require("@ethersproject/signing-key");
31
+ const ethers_1 = require("ethers");
29
32
  const types_js_1 = require("../types.js");
30
33
  function sleep(ms) {
31
34
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -67,6 +70,16 @@ exports.defaultProdAoConfigs = {
67
70
  };
68
71
  function createTurboSigner({ signer: clientProvidedSigner, privateKey: clientProvidedPrivateKey, token = 'arweave', }) {
69
72
  if (clientProvidedSigner !== undefined) {
73
+ if (clientProvidedSigner instanceof arbundles_1.InjectedEthereumSigner) {
74
+ // Override the setPublicKey method to resolve a generic string to sign
75
+ clientProvidedSigner.setPublicKey = async () => {
76
+ const message = 'sign this message to connect to your account';
77
+ const signedMsg = await clientProvidedSigner['signer'].signMessage(message);
78
+ const hash = (0, ethers_1.hashMessage)(message);
79
+ const recoveredKey = (0, signing_key_1.recoverPublicKey)((0, bytes_1.arrayify)(hash), signedMsg);
80
+ this.publicKey = Buffer.from((0, bytes_1.arrayify)(recoveredKey));
81
+ };
82
+ }
70
83
  return clientProvidedSigner;
71
84
  }
72
85
  if (clientProvidedPrivateKey === undefined) {
@@ -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.31.0-alpha.3';
20
+ exports.version = '1.31.1-alpha.1';
@@ -209,17 +209,17 @@ export class ChunkedUploader {
209
209
  async finalizeUpload(uploadId, dataItemByteCount, paidBy, signal) {
210
210
  // Wait up to 1 minute per GiB of data for the upload to finalize
211
211
  const fileSizeInGiB = Math.ceil(this.toGiB(dataItemByteCount));
212
- const defaultMaxWaitTimeMins = fileSizeInGiB;
213
- const maxWaitTimeMs = this.maxFinalizeMs ?? defaultMaxWaitTimeMins * 60 * 1000;
212
+ const defaultMaxWaitTimeMins = fileSizeInGiB * 2.5;
213
+ const maxWaitTimeMs = this.maxFinalizeMs ?? Math.floor(defaultMaxWaitTimeMins * 60 * 1000);
214
214
  const minimumWaitPerStepMs =
215
215
  // Per step, files smaller than 100MB will wait 2 second,
216
216
  dataItemByteCount < 1024 * 1024 * 100
217
217
  ? 2000
218
- : // files smaller than 3 GiB will wait 3 seconds,
218
+ : // files smaller than 3 GiB will wait 4 seconds,
219
219
  dataItemByteCount < 1024 * 1024 * 1024 * 3
220
- ? 3000
221
- : // and larger files will wait 1 second per GiB with max of 10 seconds
222
- Math.max(1000 * fileSizeInGiB, 10000);
220
+ ? 4000
221
+ : // and larger files will wait 1.5 second per GiB with max of 15 seconds
222
+ Math.max(1500 * fileSizeInGiB, 15000);
223
223
  const paidByHeader = {};
224
224
  if (paidBy !== undefined) {
225
225
  paidByHeader['x-paid-by'] = Array.isArray(paidBy)
@@ -236,7 +236,7 @@ export class ChunkedUploader {
236
236
  },
237
237
  signal,
238
238
  });
239
- this.logger.debug(`Confirming upload to Turbo with uploadId ${uploadId} for up to ${defaultMaxWaitTimeMins} minutes.`);
239
+ this.logger.debug(`Confirming upload to Turbo with uploadId ${uploadId} for up to ${maxWaitTimeMs / 1000 / 60} minutes.`);
240
240
  const startTime = Date.now();
241
241
  const cutoffTime = startTime + maxWaitTimeMs;
242
242
  let attempts = 0;
@@ -120,7 +120,8 @@ export class TurboBaseFactory {
120
120
  }
121
121
  return new HexInjectedSolanaSigner(walletAdapter);
122
122
  }
123
- if (token === 'ethereum') {
123
+ const ethTokens = new Set(['ethereum', 'base-eth']);
124
+ if (ethTokens.has(token)) {
124
125
  if (!isEthereumWalletAdapter(walletAdapter)) {
125
126
  throw new Error('Unsupported wallet adapter -- must implement getSigner');
126
127
  }
@@ -16,7 +16,10 @@
16
16
  import { Secp256k1HdWallet, makeCosmoshubPath } from '@cosmjs/amino';
17
17
  import { Slip10, Slip10Curve } from '@cosmjs/crypto';
18
18
  import { toHex } from '@cosmjs/encoding';
19
- import { ArweaveSigner, EthereumSigner, HexSolanaSigner, } from '@dha-team/arbundles';
19
+ import { ArweaveSigner, EthereumSigner, HexSolanaSigner, InjectedEthereumSigner, } from '@dha-team/arbundles';
20
+ import { arrayify } from '@ethersproject/bytes';
21
+ import { recoverPublicKey } from '@ethersproject/signing-key';
22
+ import { hashMessage } from 'ethers';
20
23
  import { isEthPrivateKey, isJWK, isKyvePrivateKey, } from '../types.js';
21
24
  export function sleep(ms) {
22
25
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -58,6 +61,16 @@ export const defaultProdAoConfigs = {
58
61
  };
59
62
  export function createTurboSigner({ signer: clientProvidedSigner, privateKey: clientProvidedPrivateKey, token = 'arweave', }) {
60
63
  if (clientProvidedSigner !== undefined) {
64
+ if (clientProvidedSigner instanceof InjectedEthereumSigner) {
65
+ // Override the setPublicKey method to resolve a generic string to sign
66
+ clientProvidedSigner.setPublicKey = async () => {
67
+ const message = 'sign this message to connect to your account';
68
+ const signedMsg = await clientProvidedSigner['signer'].signMessage(message);
69
+ const hash = hashMessage(message);
70
+ const recoveredKey = recoverPublicKey(arrayify(hash), signedMsg);
71
+ this.publicKey = Buffer.from(arrayify(recoveredKey));
72
+ };
73
+ }
61
74
  return clientProvidedSigner;
62
75
  }
63
76
  if (clientProvidedPrivateKey === undefined) {
@@ -14,4 +14,4 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
17
- export const version = '1.31.0-alpha.3';
17
+ export const version = '1.31.1-alpha.1';
@@ -1 +1 @@
1
- {"version":3,"file":"chunked.d.ts","sourceRoot":"","sources":["../../../src/common/chunked.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,EACL,SAAS,EAET,iBAAiB,EACjB,WAAW,EAEX,2BAA2B,EAC3B,0BAA0B,EAG3B,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAK7C,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAK5C,eAAO,MAAM,iBAAiB,QAAiB,CAAC;AAChD,eAAO,MAAM,iBAAiB,QAAU,CAAC;AACzC,eAAO,MAAM,qBAAqB,QAAoB,CAAC;AAKvD;;;GAGG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAS;IAC7C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAqB;IACnD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAmB;IACxC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;IAErC,SAAgB,sBAAsB,EAAE,OAAO,CAAC;IAChD,OAAO,CAAC,eAAe,CAAS;gBAEpB,EACV,IAAI,EACJ,KAAK,EACL,mBAAgD,EAChD,aAAa,EACb,cAAsC,EACtC,MAAmC,EACnC,YAAqB,EACrB,iBAAiB,GAClB,EAAE;QACD,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,IAAI,EAAE,gBAAgB,CAAC;QACvB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,WAAW,CAAC;QACpB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC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B;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,IAAI,CAEhD"}
@@ -13,5 +13,5 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export declare const version = "1.31.0-alpha.2";
16
+ export declare const version = "1.31.0";
17
17
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,eAAO,MAAM,OAAO,mBAAmB,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,eAAO,MAAM,OAAO,WAAW,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ardrive/turbo-sdk",
3
- "version": "1.31.0-alpha.3",
3
+ "version": "1.31.1-alpha.1",
4
4
  "main": "./lib/cjs/node/index.js",
5
5
  "types": "./lib/types/node/index.d.ts",
6
6
  "module": "./lib/esm/node/index.js",