@ardrive/turbo-sdk 1.31.1 → 1.32.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.
- package/README.md +37 -0
- package/bundles/web.bundle.min.js +466 -258
- package/lib/cjs/cli/commands/uploadFile.js +1 -0
- package/lib/cjs/cli/commands/uploadFolder.js +1 -0
- package/lib/cjs/cli/options.js +19 -0
- package/lib/cjs/cli/utils.js +25 -0
- package/lib/cjs/common/factory.js +1 -0
- package/lib/cjs/common/payment.js +1 -1
- package/lib/cjs/common/signer.js +21 -0
- package/lib/cjs/common/token/ario.js +1 -1
- package/lib/cjs/common/token/arweave.js +1 -1
- package/lib/cjs/common/token/baseEth.js +17 -1
- package/lib/cjs/common/token/ethereum.js +13 -4
- package/lib/cjs/common/token/kyve.js +1 -1
- package/lib/cjs/common/token/solana.js +10 -1
- package/lib/cjs/common/turbo.js +3 -1
- package/lib/cjs/common/upload.js +124 -6
- package/lib/cjs/node/upload.js +2 -1
- package/lib/cjs/types.js +20 -1
- package/lib/cjs/version.js +1 -1
- package/lib/cjs/web/upload.js +2 -2
- package/lib/esm/cli/commands/uploadFile.js +2 -1
- package/lib/esm/cli/commands/uploadFolder.js +2 -1
- package/lib/esm/cli/options.js +19 -0
- package/lib/esm/cli/utils.js +25 -1
- package/lib/esm/common/factory.js +1 -0
- package/lib/esm/common/payment.js +1 -1
- package/lib/esm/common/signer.js +22 -1
- package/lib/esm/common/token/ario.js +1 -1
- package/lib/esm/common/token/arweave.js +1 -1
- package/lib/esm/common/token/baseEth.js +17 -1
- package/lib/esm/common/token/ethereum.js +13 -4
- package/lib/esm/common/token/kyve.js +1 -1
- package/lib/esm/common/token/solana.js +10 -1
- package/lib/esm/common/turbo.js +3 -1
- package/lib/esm/common/upload.js +124 -6
- package/lib/esm/node/upload.js +2 -1
- package/lib/esm/types.js +17 -0
- package/lib/esm/version.js +1 -1
- package/lib/esm/web/upload.js +2 -2
- package/lib/types/cli/commands/uploadFile.d.ts.map +1 -1
- package/lib/types/cli/commands/uploadFolder.d.ts.map +1 -1
- package/lib/types/cli/options.d.ts +43 -0
- package/lib/types/cli/options.d.ts.map +1 -1
- package/lib/types/cli/types.d.ts +4 -0
- package/lib/types/cli/types.d.ts.map +1 -1
- package/lib/types/cli/utils.d.ts +4 -1
- package/lib/types/cli/utils.d.ts.map +1 -1
- package/lib/types/common/factory.d.ts +4 -1
- package/lib/types/common/factory.d.ts.map +1 -1
- package/lib/types/common/signer.d.ts.map +1 -1
- package/lib/types/common/token/ario.d.ts +1 -1
- package/lib/types/common/token/ario.d.ts.map +1 -1
- package/lib/types/common/token/arweave.d.ts +1 -1
- package/lib/types/common/token/arweave.d.ts.map +1 -1
- package/lib/types/common/token/baseEth.d.ts +1 -0
- package/lib/types/common/token/baseEth.d.ts.map +1 -1
- package/lib/types/common/token/ethereum.d.ts +2 -1
- package/lib/types/common/token/ethereum.d.ts.map +1 -1
- package/lib/types/common/token/kyve.d.ts +1 -1
- package/lib/types/common/token/kyve.d.ts.map +1 -1
- package/lib/types/common/token/solana.d.ts +1 -16
- package/lib/types/common/token/solana.d.ts.map +1 -1
- package/lib/types/common/turbo.d.ts +2 -2
- package/lib/types/common/turbo.d.ts.map +1 -1
- package/lib/types/common/upload.d.ts +16 -3
- package/lib/types/common/upload.d.ts.map +1 -1
- package/lib/types/node/factory.d.ts +4 -1
- package/lib/types/node/factory.d.ts.map +1 -1
- package/lib/types/node/upload.d.ts +4 -1
- package/lib/types/node/upload.d.ts.map +1 -1
- package/lib/types/types.d.ts +26 -6
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/version.d.ts +1 -1
- package/lib/types/version.d.ts.map +1 -1
- package/lib/types/web/factory.d.ts +4 -1
- package/lib/types/web/factory.d.ts.map +1 -1
- package/lib/types/web/upload.d.ts +4 -1
- package/lib/types/web/upload.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -220860,162 +220860,6 @@ globalThis.arbundles ??= expObj;
|
|
|
220860
220860
|
init_dirname();
|
|
220861
220861
|
init_buffer2();
|
|
220862
220862
|
init_process2();
|
|
220863
|
-
var fiatCurrencyTypes = [
|
|
220864
|
-
"usd",
|
|
220865
|
-
"eur",
|
|
220866
|
-
"gbp",
|
|
220867
|
-
"cad",
|
|
220868
|
-
"aud",
|
|
220869
|
-
"jpy",
|
|
220870
|
-
"inr",
|
|
220871
|
-
"sgd",
|
|
220872
|
-
"hkd",
|
|
220873
|
-
"brl"
|
|
220874
|
-
];
|
|
220875
|
-
function isCurrency(currency) {
|
|
220876
|
-
return fiatCurrencyTypes.includes(currency);
|
|
220877
|
-
}
|
|
220878
|
-
var tokenTypes = [
|
|
220879
|
-
"arweave",
|
|
220880
|
-
"ario",
|
|
220881
|
-
"solana",
|
|
220882
|
-
"ethereum",
|
|
220883
|
-
"kyve",
|
|
220884
|
-
"matic",
|
|
220885
|
-
"pol",
|
|
220886
|
-
"base-eth"
|
|
220887
|
-
];
|
|
220888
|
-
var multipartPendingStatus = [
|
|
220889
|
-
"ASSEMBLING",
|
|
220890
|
-
"VALIDATING",
|
|
220891
|
-
"FINALIZING"
|
|
220892
|
-
];
|
|
220893
|
-
var multipartFailedStatus = [
|
|
220894
|
-
"UNDERFUNDED",
|
|
220895
|
-
"INVALID",
|
|
220896
|
-
"APPROVAL_FAILED",
|
|
220897
|
-
"REVOKE_FAILED"
|
|
220898
|
-
];
|
|
220899
|
-
var multipartFinalizedStatus = ["FINALIZED"];
|
|
220900
|
-
var isNodeUploadFolderParams = (p9) => p9.folderPath !== void 0;
|
|
220901
|
-
var isWebUploadFolderParams = (p9) => p9.files !== void 0;
|
|
220902
|
-
function isKyvePrivateKey(wallet) {
|
|
220903
|
-
if (typeof wallet !== "string")
|
|
220904
|
-
return false;
|
|
220905
|
-
return true;
|
|
220906
|
-
}
|
|
220907
|
-
function isEthPrivateKey(wallet) {
|
|
220908
|
-
if (typeof wallet !== "string")
|
|
220909
|
-
return false;
|
|
220910
|
-
return wallet.startsWith("0x");
|
|
220911
|
-
}
|
|
220912
|
-
var isJWK = (wallet) => wallet.kty !== void 0;
|
|
220913
|
-
function isSolanaWalletAdapter(walletAdapter) {
|
|
220914
|
-
return "publicKey" in walletAdapter && "signMessage" in walletAdapter;
|
|
220915
|
-
}
|
|
220916
|
-
function isEthereumWalletAdapter(walletAdapter) {
|
|
220917
|
-
return "getSigner" in walletAdapter;
|
|
220918
|
-
}
|
|
220919
|
-
var validChunkingModes = ["force", "disabled", "auto"];
|
|
220920
|
-
|
|
220921
|
-
// src/common/logger.ts
|
|
220922
|
-
init_dirname();
|
|
220923
|
-
init_buffer2();
|
|
220924
|
-
init_process2();
|
|
220925
|
-
var import_winston = __toESM(require_winston(), 1);
|
|
220926
|
-
|
|
220927
|
-
// src/version.ts
|
|
220928
|
-
init_dirname();
|
|
220929
|
-
init_buffer2();
|
|
220930
|
-
init_process2();
|
|
220931
|
-
var version21 = "1.31.1-alpha.2";
|
|
220932
|
-
|
|
220933
|
-
// src/common/logger.ts
|
|
220934
|
-
var TurboWinstonLogger = class _TurboWinstonLogger {
|
|
220935
|
-
constructor({
|
|
220936
|
-
level = "info",
|
|
220937
|
-
logFormat = "simple"
|
|
220938
|
-
} = {}) {
|
|
220939
|
-
this.silent = false;
|
|
220940
|
-
if (level === "none") {
|
|
220941
|
-
this.silent = true;
|
|
220942
|
-
}
|
|
220943
|
-
if (typeof window !== "undefined") {
|
|
220944
|
-
this.logger = console;
|
|
220945
|
-
} else {
|
|
220946
|
-
this.logger = (0, import_winston.createLogger)({
|
|
220947
|
-
level,
|
|
220948
|
-
silent: this.silent,
|
|
220949
|
-
defaultMeta: {
|
|
220950
|
-
name: "turbo-sdk",
|
|
220951
|
-
version: version21
|
|
220952
|
-
},
|
|
220953
|
-
format: import_winston.format.combine(import_winston.format.timestamp(), import_winston.format.json()),
|
|
220954
|
-
transports: [
|
|
220955
|
-
new import_winston.transports.Console({
|
|
220956
|
-
format: getLogFormat(logFormat)
|
|
220957
|
-
})
|
|
220958
|
-
]
|
|
220959
|
-
});
|
|
220960
|
-
}
|
|
220961
|
-
}
|
|
220962
|
-
static {
|
|
220963
|
-
this.default = new _TurboWinstonLogger();
|
|
220964
|
-
}
|
|
220965
|
-
info(message2, ...args) {
|
|
220966
|
-
if (this.silent)
|
|
220967
|
-
return;
|
|
220968
|
-
this.logger.info(message2, ...args);
|
|
220969
|
-
}
|
|
220970
|
-
warn(message2, ...args) {
|
|
220971
|
-
if (this.silent)
|
|
220972
|
-
return;
|
|
220973
|
-
this.logger.warn(message2, ...args);
|
|
220974
|
-
}
|
|
220975
|
-
error(message2, ...args) {
|
|
220976
|
-
if (this.silent)
|
|
220977
|
-
return;
|
|
220978
|
-
this.logger.error(message2, ...args);
|
|
220979
|
-
}
|
|
220980
|
-
debug(message2, ...args) {
|
|
220981
|
-
if (this.silent)
|
|
220982
|
-
return;
|
|
220983
|
-
this.logger.debug(message2, ...args);
|
|
220984
|
-
}
|
|
220985
|
-
setLogLevel(level) {
|
|
220986
|
-
this.silent = level === "none";
|
|
220987
|
-
if ("silent" in this.logger) {
|
|
220988
|
-
this.logger.silent = level === "none";
|
|
220989
|
-
}
|
|
220990
|
-
if ("level" in this.logger) {
|
|
220991
|
-
this.logger.level = level;
|
|
220992
|
-
}
|
|
220993
|
-
}
|
|
220994
|
-
setLogFormat(logFormat) {
|
|
220995
|
-
if ("format" in this.logger) {
|
|
220996
|
-
this.logger.format = getLogFormat(logFormat);
|
|
220997
|
-
}
|
|
220998
|
-
}
|
|
220999
|
-
};
|
|
221000
|
-
function getLogFormat(logFormat) {
|
|
221001
|
-
return import_winston.format.combine(
|
|
221002
|
-
(0, import_winston.format)((info) => {
|
|
221003
|
-
if (info.stack && info.level !== "error") {
|
|
221004
|
-
delete info.stack;
|
|
221005
|
-
}
|
|
221006
|
-
return info;
|
|
221007
|
-
})(),
|
|
221008
|
-
import_winston.format.errors({ stack: true }),
|
|
221009
|
-
// Ensure errors show a stack trace
|
|
221010
|
-
import_winston.format.timestamp(),
|
|
221011
|
-
logFormat === "json" ? import_winston.format.json() : import_winston.format.simple()
|
|
221012
|
-
);
|
|
221013
|
-
}
|
|
221014
|
-
|
|
221015
|
-
// src/common/payment.ts
|
|
221016
|
-
init_dirname();
|
|
221017
|
-
init_buffer2();
|
|
221018
|
-
init_process2();
|
|
221019
220863
|
|
|
221020
220864
|
// node_modules/bignumber.js/bignumber.mjs
|
|
221021
220865
|
init_dirname();
|
|
@@ -222493,6 +222337,181 @@ function toFixedPoint(str, e12, z6) {
|
|
|
222493
222337
|
}
|
|
222494
222338
|
var BigNumber2 = clone();
|
|
222495
222339
|
|
|
222340
|
+
// src/types.ts
|
|
222341
|
+
var fiatCurrencyTypes = [
|
|
222342
|
+
"usd",
|
|
222343
|
+
"eur",
|
|
222344
|
+
"gbp",
|
|
222345
|
+
"cad",
|
|
222346
|
+
"aud",
|
|
222347
|
+
"jpy",
|
|
222348
|
+
"inr",
|
|
222349
|
+
"sgd",
|
|
222350
|
+
"hkd",
|
|
222351
|
+
"brl"
|
|
222352
|
+
];
|
|
222353
|
+
function isCurrency(currency) {
|
|
222354
|
+
return fiatCurrencyTypes.includes(currency);
|
|
222355
|
+
}
|
|
222356
|
+
var tokenTypes = [
|
|
222357
|
+
"arweave",
|
|
222358
|
+
"ario",
|
|
222359
|
+
"solana",
|
|
222360
|
+
"ethereum",
|
|
222361
|
+
"kyve",
|
|
222362
|
+
"matic",
|
|
222363
|
+
"pol",
|
|
222364
|
+
"base-eth"
|
|
222365
|
+
];
|
|
222366
|
+
var ExistingBalanceFunding = class {
|
|
222367
|
+
};
|
|
222368
|
+
var OnDemandFunding = class {
|
|
222369
|
+
constructor({
|
|
222370
|
+
maxTokenAmount,
|
|
222371
|
+
topUpBufferMultiplier = 1.1
|
|
222372
|
+
}) {
|
|
222373
|
+
if (maxTokenAmount !== void 0 && new BigNumber2(maxTokenAmount).isLessThan(0)) {
|
|
222374
|
+
throw new Error("maxTokenAmount must be non-negative");
|
|
222375
|
+
}
|
|
222376
|
+
this.maxTokenAmount = maxTokenAmount !== void 0 ? new BigNumber2(maxTokenAmount) : void 0;
|
|
222377
|
+
if (topUpBufferMultiplier < 1) {
|
|
222378
|
+
throw new Error("topUpBufferMultiplier must be >= 1");
|
|
222379
|
+
}
|
|
222380
|
+
this.topUpBufferMultiplier = topUpBufferMultiplier;
|
|
222381
|
+
}
|
|
222382
|
+
};
|
|
222383
|
+
var multipartPendingStatus = [
|
|
222384
|
+
"ASSEMBLING",
|
|
222385
|
+
"VALIDATING",
|
|
222386
|
+
"FINALIZING"
|
|
222387
|
+
];
|
|
222388
|
+
var multipartFailedStatus = [
|
|
222389
|
+
"UNDERFUNDED",
|
|
222390
|
+
"INVALID",
|
|
222391
|
+
"APPROVAL_FAILED",
|
|
222392
|
+
"REVOKE_FAILED"
|
|
222393
|
+
];
|
|
222394
|
+
var multipartFinalizedStatus = ["FINALIZED"];
|
|
222395
|
+
var isNodeUploadFolderParams = (p9) => p9.folderPath !== void 0;
|
|
222396
|
+
var isWebUploadFolderParams = (p9) => p9.files !== void 0;
|
|
222397
|
+
function isKyvePrivateKey(wallet) {
|
|
222398
|
+
if (typeof wallet !== "string")
|
|
222399
|
+
return false;
|
|
222400
|
+
return true;
|
|
222401
|
+
}
|
|
222402
|
+
function isEthPrivateKey(wallet) {
|
|
222403
|
+
if (typeof wallet !== "string")
|
|
222404
|
+
return false;
|
|
222405
|
+
return wallet.startsWith("0x");
|
|
222406
|
+
}
|
|
222407
|
+
var isJWK = (wallet) => wallet.kty !== void 0;
|
|
222408
|
+
function isSolanaWalletAdapter(walletAdapter) {
|
|
222409
|
+
return "publicKey" in walletAdapter && "signMessage" in walletAdapter;
|
|
222410
|
+
}
|
|
222411
|
+
function isEthereumWalletAdapter(walletAdapter) {
|
|
222412
|
+
return "getSigner" in walletAdapter;
|
|
222413
|
+
}
|
|
222414
|
+
var validChunkingModes = ["force", "disabled", "auto"];
|
|
222415
|
+
|
|
222416
|
+
// src/common/logger.ts
|
|
222417
|
+
init_dirname();
|
|
222418
|
+
init_buffer2();
|
|
222419
|
+
init_process2();
|
|
222420
|
+
var import_winston = __toESM(require_winston(), 1);
|
|
222421
|
+
|
|
222422
|
+
// src/version.ts
|
|
222423
|
+
init_dirname();
|
|
222424
|
+
init_buffer2();
|
|
222425
|
+
init_process2();
|
|
222426
|
+
var version21 = "1.31.1";
|
|
222427
|
+
|
|
222428
|
+
// src/common/logger.ts
|
|
222429
|
+
var TurboWinstonLogger = class _TurboWinstonLogger {
|
|
222430
|
+
constructor({
|
|
222431
|
+
level = "info",
|
|
222432
|
+
logFormat = "simple"
|
|
222433
|
+
} = {}) {
|
|
222434
|
+
this.silent = false;
|
|
222435
|
+
if (level === "none") {
|
|
222436
|
+
this.silent = true;
|
|
222437
|
+
}
|
|
222438
|
+
if (typeof window !== "undefined") {
|
|
222439
|
+
this.logger = console;
|
|
222440
|
+
} else {
|
|
222441
|
+
this.logger = (0, import_winston.createLogger)({
|
|
222442
|
+
level,
|
|
222443
|
+
silent: this.silent,
|
|
222444
|
+
defaultMeta: {
|
|
222445
|
+
name: "turbo-sdk",
|
|
222446
|
+
version: version21
|
|
222447
|
+
},
|
|
222448
|
+
format: import_winston.format.combine(import_winston.format.timestamp(), import_winston.format.json()),
|
|
222449
|
+
transports: [
|
|
222450
|
+
new import_winston.transports.Console({
|
|
222451
|
+
format: getLogFormat(logFormat)
|
|
222452
|
+
})
|
|
222453
|
+
]
|
|
222454
|
+
});
|
|
222455
|
+
}
|
|
222456
|
+
}
|
|
222457
|
+
static {
|
|
222458
|
+
this.default = new _TurboWinstonLogger();
|
|
222459
|
+
}
|
|
222460
|
+
info(message2, ...args) {
|
|
222461
|
+
if (this.silent)
|
|
222462
|
+
return;
|
|
222463
|
+
this.logger.info(message2, ...args);
|
|
222464
|
+
}
|
|
222465
|
+
warn(message2, ...args) {
|
|
222466
|
+
if (this.silent)
|
|
222467
|
+
return;
|
|
222468
|
+
this.logger.warn(message2, ...args);
|
|
222469
|
+
}
|
|
222470
|
+
error(message2, ...args) {
|
|
222471
|
+
if (this.silent)
|
|
222472
|
+
return;
|
|
222473
|
+
this.logger.error(message2, ...args);
|
|
222474
|
+
}
|
|
222475
|
+
debug(message2, ...args) {
|
|
222476
|
+
if (this.silent)
|
|
222477
|
+
return;
|
|
222478
|
+
this.logger.debug(message2, ...args);
|
|
222479
|
+
}
|
|
222480
|
+
setLogLevel(level) {
|
|
222481
|
+
this.silent = level === "none";
|
|
222482
|
+
if ("silent" in this.logger) {
|
|
222483
|
+
this.logger.silent = level === "none";
|
|
222484
|
+
}
|
|
222485
|
+
if ("level" in this.logger) {
|
|
222486
|
+
this.logger.level = level;
|
|
222487
|
+
}
|
|
222488
|
+
}
|
|
222489
|
+
setLogFormat(logFormat) {
|
|
222490
|
+
if ("format" in this.logger) {
|
|
222491
|
+
this.logger.format = getLogFormat(logFormat);
|
|
222492
|
+
}
|
|
222493
|
+
}
|
|
222494
|
+
};
|
|
222495
|
+
function getLogFormat(logFormat) {
|
|
222496
|
+
return import_winston.format.combine(
|
|
222497
|
+
(0, import_winston.format)((info) => {
|
|
222498
|
+
if (info.stack && info.level !== "error") {
|
|
222499
|
+
delete info.stack;
|
|
222500
|
+
}
|
|
222501
|
+
return info;
|
|
222502
|
+
})(),
|
|
222503
|
+
import_winston.format.errors({ stack: true }),
|
|
222504
|
+
// Ensure errors show a stack trace
|
|
222505
|
+
import_winston.format.timestamp(),
|
|
222506
|
+
logFormat === "json" ? import_winston.format.json() : import_winston.format.simple()
|
|
222507
|
+
);
|
|
222508
|
+
}
|
|
222509
|
+
|
|
222510
|
+
// src/common/payment.ts
|
|
222511
|
+
init_dirname();
|
|
222512
|
+
init_buffer2();
|
|
222513
|
+
init_process2();
|
|
222514
|
+
|
|
222496
222515
|
// src/utils/axiosClient.ts
|
|
222497
222516
|
init_dirname();
|
|
222498
222517
|
init_buffer2();
|
|
@@ -262493,7 +262512,7 @@ var ARIOToken = class {
|
|
|
262493
262512
|
});
|
|
262494
262513
|
return { id: txId, target, reward: "0" };
|
|
262495
262514
|
}
|
|
262496
|
-
async
|
|
262515
|
+
async pollTxAvailability() {
|
|
262497
262516
|
return sleep(this.pollingOptions.initialBackoffMs);
|
|
262498
262517
|
}
|
|
262499
262518
|
};
|
|
@@ -262621,9 +262640,7 @@ var ArweaveToken = class {
|
|
|
262621
262640
|
await this.submitTx(tx);
|
|
262622
262641
|
return { id: id3, target, reward: tx.reward };
|
|
262623
262642
|
}
|
|
262624
|
-
async
|
|
262625
|
-
txId
|
|
262626
|
-
}) {
|
|
262643
|
+
async pollTxAvailability({ txId }) {
|
|
262627
262644
|
const { maxAttempts, pollingIntervalMs, initialBackoffMs } = this.pollingOptions;
|
|
262628
262645
|
this.logger.debug("Polling for transaction...", { txId });
|
|
262629
262646
|
await sleep(initialBackoffMs);
|
|
@@ -262734,17 +262751,24 @@ var EthereumToken = class {
|
|
|
262734
262751
|
target
|
|
262735
262752
|
};
|
|
262736
262753
|
}
|
|
262737
|
-
async
|
|
262738
|
-
txId
|
|
262739
|
-
|
|
262754
|
+
async getTxAvailability(txId) {
|
|
262755
|
+
const tx = await this.rpcProvider.getTransaction(txId);
|
|
262756
|
+
if (tx) {
|
|
262757
|
+
this.logger.debug("Transaction is available on chain", { txId, tx });
|
|
262758
|
+
return true;
|
|
262759
|
+
}
|
|
262760
|
+
this.logger.debug("Transaction not yet available on chain", { txId });
|
|
262761
|
+
return false;
|
|
262762
|
+
}
|
|
262763
|
+
async pollTxAvailability({ txId }) {
|
|
262740
262764
|
await new Promise(
|
|
262741
262765
|
(resolve3) => setTimeout(resolve3, this.pollingOptions.initialBackoffMs)
|
|
262742
262766
|
);
|
|
262743
262767
|
let attempts = 0;
|
|
262744
262768
|
while (attempts < this.pollingOptions.maxAttempts) {
|
|
262745
262769
|
try {
|
|
262746
|
-
const
|
|
262747
|
-
if (
|
|
262770
|
+
const txIsAvailable = await this.getTxAvailability(txId);
|
|
262771
|
+
if (txIsAvailable) {
|
|
262748
262772
|
return;
|
|
262749
262773
|
}
|
|
262750
262774
|
} catch (e12) {
|
|
@@ -262755,7 +262779,7 @@ var EthereumToken = class {
|
|
|
262755
262779
|
);
|
|
262756
262780
|
attempts++;
|
|
262757
262781
|
}
|
|
262758
|
-
throw new Error(
|
|
262782
|
+
throw new Error(`Transaction ${txId} not found after polling!`);
|
|
262759
262783
|
}
|
|
262760
262784
|
};
|
|
262761
262785
|
|
|
@@ -262765,7 +262789,7 @@ var BaseEthToken = class extends EthereumToken {
|
|
|
262765
262789
|
logger: logger19,
|
|
262766
262790
|
gatewayUrl = defaultProdGatewayUrls["base-eth"],
|
|
262767
262791
|
pollingOptions = {
|
|
262768
|
-
initialBackoffMs:
|
|
262792
|
+
initialBackoffMs: 2500,
|
|
262769
262793
|
maxAttempts: 10,
|
|
262770
262794
|
pollingIntervalMs: 2500
|
|
262771
262795
|
}
|
|
@@ -262776,6 +262800,22 @@ var BaseEthToken = class extends EthereumToken {
|
|
|
262776
262800
|
pollingOptions
|
|
262777
262801
|
});
|
|
262778
262802
|
}
|
|
262803
|
+
async getTxAvailability(txId) {
|
|
262804
|
+
const tx = await this.rpcProvider.getTransactionReceipt(txId);
|
|
262805
|
+
if (tx) {
|
|
262806
|
+
const confirmations = await tx.confirmations();
|
|
262807
|
+
if (confirmations >= 1) {
|
|
262808
|
+
this.logger.debug("Transaction is available on chain", {
|
|
262809
|
+
txId,
|
|
262810
|
+
tx,
|
|
262811
|
+
confirmations
|
|
262812
|
+
});
|
|
262813
|
+
return true;
|
|
262814
|
+
}
|
|
262815
|
+
}
|
|
262816
|
+
this.logger.debug("Transaction not yet available on chain", { txId, tx });
|
|
262817
|
+
return false;
|
|
262818
|
+
}
|
|
262779
262819
|
};
|
|
262780
262820
|
|
|
262781
262821
|
// src/common/token/kyve.ts
|
|
@@ -262825,9 +262865,7 @@ var KyveToken = class {
|
|
|
262825
262865
|
});
|
|
262826
262866
|
return { id: txHash, target };
|
|
262827
262867
|
}
|
|
262828
|
-
async
|
|
262829
|
-
txId
|
|
262830
|
-
}) {
|
|
262868
|
+
async pollTxAvailability({ txId }) {
|
|
262831
262869
|
const { maxAttempts, pollingIntervalMs, initialBackoffMs } = this.pollingOptions;
|
|
262832
262870
|
this.logger.debug("Polling for transaction...", {
|
|
262833
262871
|
txId,
|
|
@@ -273602,6 +273640,14 @@ var SolanaToken = class {
|
|
|
273602
273640
|
tokenAmount,
|
|
273603
273641
|
signer
|
|
273604
273642
|
}) {
|
|
273643
|
+
if (signer.signer instanceof HexSolanaSigner) {
|
|
273644
|
+
const id4 = await signer.sendTransaction({
|
|
273645
|
+
amount: tokenAmount,
|
|
273646
|
+
target,
|
|
273647
|
+
gatewayUrl: this.gatewayUrl
|
|
273648
|
+
});
|
|
273649
|
+
return { target, id: id4 };
|
|
273650
|
+
}
|
|
273605
273651
|
const publicKey2 = new PublicKey(
|
|
273606
273652
|
import_bs583.default.encode(Uint8Array.from(await signer.getPublicKey()))
|
|
273607
273653
|
);
|
|
@@ -273642,9 +273688,7 @@ var SolanaToken = class {
|
|
|
273642
273688
|
"finalized"
|
|
273643
273689
|
);
|
|
273644
273690
|
}
|
|
273645
|
-
async
|
|
273646
|
-
txId
|
|
273647
|
-
}) {
|
|
273691
|
+
async pollTxAvailability({ txId }) {
|
|
273648
273692
|
const { maxAttempts, pollingIntervalMs, initialBackoffMs } = this.pollingOptions;
|
|
273649
273693
|
this.logger.debug("Polling for transaction...", {
|
|
273650
273694
|
txId,
|
|
@@ -274021,7 +274065,7 @@ var TurboAuthenticatedPaymentService = class extends TurboUnauthenticatedPayment
|
|
|
274021
274065
|
});
|
|
274022
274066
|
const txId = fundTx.id;
|
|
274023
274067
|
try {
|
|
274024
|
-
await this.tokenTools.
|
|
274068
|
+
await this.tokenTools.pollTxAvailability({ txId });
|
|
274025
274069
|
} catch (e12) {
|
|
274026
274070
|
this.logger.error(
|
|
274027
274071
|
`Failed to poll for transaction being available from ${this.token} gateway... Attempting to submit fund tx to Turbo...`,
|
|
@@ -274809,6 +274853,77 @@ function combineAbortSignals(signals) {
|
|
|
274809
274853
|
return controller.signal;
|
|
274810
274854
|
}
|
|
274811
274855
|
|
|
274856
|
+
// src/common/index.ts
|
|
274857
|
+
init_dirname();
|
|
274858
|
+
init_buffer2();
|
|
274859
|
+
init_process2();
|
|
274860
|
+
|
|
274861
|
+
// src/common/currency.ts
|
|
274862
|
+
init_dirname();
|
|
274863
|
+
init_buffer2();
|
|
274864
|
+
init_process2();
|
|
274865
|
+
var ZeroDecimalCurrency = class {
|
|
274866
|
+
constructor(amt, type4) {
|
|
274867
|
+
this.amt = amt;
|
|
274868
|
+
this.type = type4;
|
|
274869
|
+
if (amt < 0) {
|
|
274870
|
+
throw new ProvidedInputError(
|
|
274871
|
+
`${type4} currency amount cannot be negative`
|
|
274872
|
+
);
|
|
274873
|
+
}
|
|
274874
|
+
this.assertDecimalPlaces(amt);
|
|
274875
|
+
}
|
|
274876
|
+
assertDecimalPlaces(a8) {
|
|
274877
|
+
if (a8 % 1 !== 0) {
|
|
274878
|
+
throw new ProvidedInputError(
|
|
274879
|
+
`${this.type} currency amount must have zero decimal places`
|
|
274880
|
+
);
|
|
274881
|
+
}
|
|
274882
|
+
}
|
|
274883
|
+
get amount() {
|
|
274884
|
+
return this.amt;
|
|
274885
|
+
}
|
|
274886
|
+
};
|
|
274887
|
+
var TwoDecimalCurrency = class extends ZeroDecimalCurrency {
|
|
274888
|
+
constructor(a8, type4) {
|
|
274889
|
+
super(a8, type4);
|
|
274890
|
+
this.a = a8;
|
|
274891
|
+
this.type = type4;
|
|
274892
|
+
}
|
|
274893
|
+
assertDecimalPlaces(a8) {
|
|
274894
|
+
if (a8 * 100 % 1 !== 0) {
|
|
274895
|
+
throw new ProvidedInputError(
|
|
274896
|
+
`${this.type} currency amount must have two decimal places`
|
|
274897
|
+
);
|
|
274898
|
+
}
|
|
274899
|
+
}
|
|
274900
|
+
get amount() {
|
|
274901
|
+
return this.a * 100;
|
|
274902
|
+
}
|
|
274903
|
+
};
|
|
274904
|
+
var USD = (usd) => new TwoDecimalCurrency(usd, "usd");
|
|
274905
|
+
var EUR = (eur) => new TwoDecimalCurrency(eur, "eur");
|
|
274906
|
+
var GBP = (gbp) => new TwoDecimalCurrency(gbp, "gbp");
|
|
274907
|
+
var CAD = (cad) => new TwoDecimalCurrency(cad, "cad");
|
|
274908
|
+
var AUD = (aud) => new TwoDecimalCurrency(aud, "aud");
|
|
274909
|
+
var INR = (inr) => new TwoDecimalCurrency(inr, "inr");
|
|
274910
|
+
var SGD = (sgd) => new TwoDecimalCurrency(sgd, "sgd");
|
|
274911
|
+
var HKD = (hkd) => new TwoDecimalCurrency(hkd, "hkd");
|
|
274912
|
+
var BRL = (brl) => new TwoDecimalCurrency(brl, "brl");
|
|
274913
|
+
var JPY = (jpy) => new ZeroDecimalCurrency(jpy, "jpy");
|
|
274914
|
+
var currencyMap = {
|
|
274915
|
+
usd: USD,
|
|
274916
|
+
eur: EUR,
|
|
274917
|
+
gbp: GBP,
|
|
274918
|
+
cad: CAD,
|
|
274919
|
+
aud: AUD,
|
|
274920
|
+
inr: INR,
|
|
274921
|
+
sgd: SGD,
|
|
274922
|
+
hkd: HKD,
|
|
274923
|
+
brl: BRL,
|
|
274924
|
+
jpy: JPY
|
|
274925
|
+
};
|
|
274926
|
+
|
|
274812
274927
|
// src/common/upload.ts
|
|
274813
274928
|
function isTurboUploadFileWithStreamFactoryParams(params) {
|
|
274814
274929
|
return "fileStreamFactory" in params;
|
|
@@ -274881,10 +274996,13 @@ var TurboAuthenticatedBaseUploadService = class extends TurboUnauthenticatedUplo
|
|
|
274881
274996
|
retryConfig,
|
|
274882
274997
|
signer,
|
|
274883
274998
|
logger: logger19,
|
|
274884
|
-
token
|
|
274999
|
+
token,
|
|
275000
|
+
paymentService
|
|
274885
275001
|
}) {
|
|
274886
275002
|
super({ url, retryConfig, logger: logger19, token });
|
|
275003
|
+
this.enabledOnDemandTokens = ["ario", "solana", "base-eth"];
|
|
274887
275004
|
this.signer = signer;
|
|
275005
|
+
this.paymentService = paymentService;
|
|
274888
275006
|
}
|
|
274889
275007
|
/**
|
|
274890
275008
|
* Signs and uploads raw data to the Turbo Upload Service.
|
|
@@ -274896,7 +275014,9 @@ var TurboAuthenticatedBaseUploadService = class extends TurboUnauthenticatedUplo
|
|
|
274896
275014
|
events,
|
|
274897
275015
|
chunkByteCount,
|
|
274898
275016
|
chunkingMode,
|
|
274899
|
-
maxChunkConcurrency
|
|
275017
|
+
maxChunkConcurrency,
|
|
275018
|
+
fundingMode,
|
|
275019
|
+
maxFinalizeMs
|
|
274900
275020
|
}) {
|
|
274901
275021
|
if (isBlob2(data)) {
|
|
274902
275022
|
const streamFactory = () => data.stream();
|
|
@@ -274906,7 +275026,12 @@ var TurboAuthenticatedBaseUploadService = class extends TurboUnauthenticatedUplo
|
|
|
274906
275026
|
fileSizeFactory: sizeFactory,
|
|
274907
275027
|
signal,
|
|
274908
275028
|
dataItemOpts,
|
|
274909
|
-
events
|
|
275029
|
+
events,
|
|
275030
|
+
chunkByteCount,
|
|
275031
|
+
chunkingMode,
|
|
275032
|
+
maxChunkConcurrency,
|
|
275033
|
+
fundingMode,
|
|
275034
|
+
maxFinalizeMs
|
|
274910
275035
|
});
|
|
274911
275036
|
}
|
|
274912
275037
|
const dataBuffer = (() => {
|
|
@@ -274925,7 +275050,9 @@ var TurboAuthenticatedBaseUploadService = class extends TurboUnauthenticatedUplo
|
|
|
274925
275050
|
events,
|
|
274926
275051
|
chunkByteCount,
|
|
274927
275052
|
chunkingMode,
|
|
274928
|
-
maxChunkConcurrency
|
|
275053
|
+
maxChunkConcurrency,
|
|
275054
|
+
fundingMode,
|
|
275055
|
+
maxFinalizeMs
|
|
274929
275056
|
});
|
|
274930
275057
|
}
|
|
274931
275058
|
resolveUploadFileConfig(params) {
|
|
@@ -274950,13 +275077,21 @@ var TurboAuthenticatedBaseUploadService = class extends TurboUnauthenticatedUplo
|
|
|
274950
275077
|
};
|
|
274951
275078
|
}
|
|
274952
275079
|
async uploadFile(params) {
|
|
274953
|
-
const {
|
|
275080
|
+
const {
|
|
275081
|
+
signal,
|
|
275082
|
+
dataItemOpts,
|
|
275083
|
+
events,
|
|
275084
|
+
fileStreamFactory,
|
|
275085
|
+
fileSizeFactory,
|
|
275086
|
+
fundingMode = new ExistingBalanceFunding()
|
|
275087
|
+
} = this.resolveUploadFileConfig(params);
|
|
274954
275088
|
let retries = 0;
|
|
274955
275089
|
const maxRetries = this.retryConfig.retries ?? 3;
|
|
274956
275090
|
const retryDelay = this.retryConfig.retryDelay ?? ((retryNumber) => retryNumber * 1e3);
|
|
274957
275091
|
let lastError = void 0;
|
|
274958
275092
|
let lastStatusCode = void 0;
|
|
274959
275093
|
const emitter = new TurboEventEmitter(events);
|
|
275094
|
+
let cryptoFundResult;
|
|
274960
275095
|
while (retries < maxRetries) {
|
|
274961
275096
|
if (signal?.aborted) {
|
|
274962
275097
|
throw new CanceledError2();
|
|
@@ -274967,6 +275102,13 @@ var TurboAuthenticatedBaseUploadService = class extends TurboUnauthenticatedUplo
|
|
|
274967
275102
|
dataItemOpts,
|
|
274968
275103
|
emitter
|
|
274969
275104
|
});
|
|
275105
|
+
if (fundingMode instanceof OnDemandFunding && cryptoFundResult === void 0) {
|
|
275106
|
+
const totalByteCount = dataItemSizeFactory();
|
|
275107
|
+
cryptoFundResult = await this.onDemand({
|
|
275108
|
+
totalByteCount,
|
|
275109
|
+
onDemandFunding: fundingMode
|
|
275110
|
+
});
|
|
275111
|
+
}
|
|
274970
275112
|
try {
|
|
274971
275113
|
const { chunkByteCount, maxChunkConcurrency } = params;
|
|
274972
275114
|
const chunkedUploader = new ChunkedUploader({
|
|
@@ -274987,7 +275129,7 @@ var TurboAuthenticatedBaseUploadService = class extends TurboUnauthenticatedUplo
|
|
|
274987
275129
|
signal,
|
|
274988
275130
|
events
|
|
274989
275131
|
});
|
|
274990
|
-
return response2;
|
|
275132
|
+
return { ...response2, cryptoFundResult };
|
|
274991
275133
|
}
|
|
274992
275134
|
const response = await this.uploadSignedDataItem({
|
|
274993
275135
|
dataItemStreamFactory,
|
|
@@ -274996,7 +275138,7 @@ var TurboAuthenticatedBaseUploadService = class extends TurboUnauthenticatedUplo
|
|
|
274996
275138
|
signal,
|
|
274997
275139
|
events
|
|
274998
275140
|
});
|
|
274999
|
-
return response;
|
|
275141
|
+
return { ...response, cryptoFundResult };
|
|
275000
275142
|
} catch (error) {
|
|
275001
275143
|
lastError = error;
|
|
275002
275144
|
if (error instanceof FailedRequestError) {
|
|
@@ -275089,6 +275231,7 @@ ${lastError instanceof Error ? lastError.message : lastError}`;
|
|
|
275089
275231
|
maxChunkConcurrency,
|
|
275090
275232
|
chunkByteCount,
|
|
275091
275233
|
chunkingMode,
|
|
275234
|
+
fundingMode = new ExistingBalanceFunding(),
|
|
275092
275235
|
maxFinalizeMs
|
|
275093
275236
|
} = params;
|
|
275094
275237
|
const { disableManifest, indexFile, fallbackFile } = manifestOptions;
|
|
@@ -275133,6 +275276,16 @@ ${lastError instanceof Error ? lastError.message : lastError}`;
|
|
|
275133
275276
|
};
|
|
275134
275277
|
const files = await this.getFiles(params);
|
|
275135
275278
|
const limit = pLimit(maxConcurrentUploads);
|
|
275279
|
+
let cryptoFundResult;
|
|
275280
|
+
if (fundingMode instanceof OnDemandFunding) {
|
|
275281
|
+
const totalByteCount = files.reduce((acc, file) => {
|
|
275282
|
+
return acc + this.getFileSize(file) + 1200;
|
|
275283
|
+
}, 0);
|
|
275284
|
+
cryptoFundResult = await this.onDemand({
|
|
275285
|
+
totalByteCount,
|
|
275286
|
+
onDemandFunding: fundingMode
|
|
275287
|
+
});
|
|
275288
|
+
}
|
|
275136
275289
|
await Promise.all(files.map((file) => limit(() => uploadFile(file))));
|
|
275137
275290
|
this.logger.debug("Finished uploading files", {
|
|
275138
275291
|
numFiles: files.length,
|
|
@@ -275170,7 +275323,8 @@ ${lastError instanceof Error ? lastError.message : lastError}`;
|
|
|
275170
275323
|
return {
|
|
275171
275324
|
...response,
|
|
275172
275325
|
manifest,
|
|
275173
|
-
manifestResponse
|
|
275326
|
+
manifestResponse,
|
|
275327
|
+
cryptoFundResult
|
|
275174
275328
|
};
|
|
275175
275329
|
}
|
|
275176
275330
|
async shareCredits({
|
|
@@ -275235,6 +275389,102 @@ ${lastError instanceof Error ? lastError.message : lastError}`;
|
|
|
275235
275389
|
}
|
|
275236
275390
|
return revokedApprovals;
|
|
275237
275391
|
}
|
|
275392
|
+
/**
|
|
275393
|
+
* Triggers an upload that will top-up the wallet with Credits for the amount before uploading.
|
|
275394
|
+
* First, it calculates the expected cost of the upload. Next, it checks the wallet for existing
|
|
275395
|
+
* balance. If the balance is insufficient, it will attempt the top-up with the wallet in the specified `token`
|
|
275396
|
+
* and await for the balance to be credited.
|
|
275397
|
+
* Note: Only `ario`, `solana`, and `base-eth` tokens are currently supported for on-demand uploads.
|
|
275398
|
+
*/
|
|
275399
|
+
async onDemand({
|
|
275400
|
+
totalByteCount,
|
|
275401
|
+
onDemandFunding
|
|
275402
|
+
}) {
|
|
275403
|
+
const { maxTokenAmount, topUpBufferMultiplier } = onDemandFunding;
|
|
275404
|
+
const currentBalance = await this.paymentService.getBalance();
|
|
275405
|
+
const wincPriceForOneGiB = (await this.paymentService.getUploadCosts({
|
|
275406
|
+
bytes: [2 ** 30]
|
|
275407
|
+
}))[0].winc;
|
|
275408
|
+
const expectedWincPrice = new BigNumber2(wincPriceForOneGiB).multipliedBy(totalByteCount).dividedBy(2 ** 30).toFixed(0, BigNumber2.ROUND_UP);
|
|
275409
|
+
if (BigNumber2(currentBalance.effectiveBalance).isGreaterThanOrEqualTo(
|
|
275410
|
+
expectedWincPrice
|
|
275411
|
+
)) {
|
|
275412
|
+
this.logger.debug("Sufficient balance for on demand upload", {
|
|
275413
|
+
currentBalance,
|
|
275414
|
+
expectedWincPrice
|
|
275415
|
+
});
|
|
275416
|
+
return void 0;
|
|
275417
|
+
}
|
|
275418
|
+
this.logger.debug("Insufficient balance for on demand upload", {
|
|
275419
|
+
currentBalance,
|
|
275420
|
+
expectedWincPrice
|
|
275421
|
+
});
|
|
275422
|
+
if (!this.enabledOnDemandTokens.includes(this.token)) {
|
|
275423
|
+
throw new Error(
|
|
275424
|
+
`On-demand uploads are not supported for token: ${this.token}`
|
|
275425
|
+
);
|
|
275426
|
+
}
|
|
275427
|
+
const topUpWincAmount = BigNumber2(expectedWincPrice).minus(currentBalance.effectiveBalance).multipliedBy(topUpBufferMultiplier).toFixed(0, BigNumber2.ROUND_UP);
|
|
275428
|
+
const wincPriceForOneToken = (await this.paymentService.getWincForToken({
|
|
275429
|
+
tokenAmount: tokenToBaseMap[this.token](1)
|
|
275430
|
+
})).winc;
|
|
275431
|
+
const topUpTokenAmount = new BigNumber2(topUpWincAmount).dividedBy(wincPriceForOneToken).multipliedBy(tokenToBaseMap[this.token](1)).toFixed(0, BigNumber2.ROUND_UP);
|
|
275432
|
+
if (maxTokenAmount !== void 0) {
|
|
275433
|
+
if (new BigNumber2(topUpTokenAmount).isGreaterThan(maxTokenAmount)) {
|
|
275434
|
+
throw new Error(
|
|
275435
|
+
`Top up token amount ${new BigNumber2(topUpTokenAmount).div(
|
|
275436
|
+
exponentMap[this.token]
|
|
275437
|
+
)} is greater than the maximum allowed amount of ${maxTokenAmount}`
|
|
275438
|
+
);
|
|
275439
|
+
}
|
|
275440
|
+
}
|
|
275441
|
+
this.logger.debug(
|
|
275442
|
+
`Topping up wallet with ${topUpTokenAmount} ${this.token} for ${topUpWincAmount} winc`
|
|
275443
|
+
);
|
|
275444
|
+
const topUpResponse = await this.paymentService.topUpWithTokens({
|
|
275445
|
+
tokenAmount: topUpTokenAmount
|
|
275446
|
+
});
|
|
275447
|
+
this.logger.debug("Top up transaction submitted", { topUpResponse });
|
|
275448
|
+
const pollingOptions = {
|
|
275449
|
+
pollIntervalMs: 3 * 1e3,
|
|
275450
|
+
// poll every 3 seconds
|
|
275451
|
+
timeoutMs: 120 * 1e3
|
|
275452
|
+
// wait up to 2 minutes
|
|
275453
|
+
};
|
|
275454
|
+
let tries = 1;
|
|
275455
|
+
const maxTries = Math.ceil(pollingOptions.timeoutMs / pollingOptions.pollIntervalMs) - 1;
|
|
275456
|
+
while (topUpResponse.status !== "confirmed" && tries < maxTries) {
|
|
275457
|
+
this.logger.debug("Tx not yet confirmed, waiting to poll again", {
|
|
275458
|
+
tries,
|
|
275459
|
+
maxTries
|
|
275460
|
+
});
|
|
275461
|
+
await sleep(pollingOptions.pollIntervalMs);
|
|
275462
|
+
tries++;
|
|
275463
|
+
try {
|
|
275464
|
+
const submitFundResult = await this.paymentService.submitFundTransaction({
|
|
275465
|
+
txId: topUpResponse.id
|
|
275466
|
+
});
|
|
275467
|
+
if (submitFundResult.status === "confirmed") {
|
|
275468
|
+
this.logger.debug(
|
|
275469
|
+
"Top-up transaction confirmed and balance updated",
|
|
275470
|
+
{ submitFundResult }
|
|
275471
|
+
);
|
|
275472
|
+
topUpResponse.status = "confirmed";
|
|
275473
|
+
break;
|
|
275474
|
+
}
|
|
275475
|
+
} catch (error) {
|
|
275476
|
+
this.logger.warn("Error fetching fund transaction during polling", {
|
|
275477
|
+
message: error instanceof Error ? error.message : error
|
|
275478
|
+
});
|
|
275479
|
+
}
|
|
275480
|
+
}
|
|
275481
|
+
if (tries >= maxTries) {
|
|
275482
|
+
this.logger.warn(
|
|
275483
|
+
"Timed out waiting for fund tx to confirm after top-up. Will continue to attempt upload but it may fail if balance is insufficient."
|
|
275484
|
+
);
|
|
275485
|
+
}
|
|
275486
|
+
return topUpResponse;
|
|
275487
|
+
}
|
|
275238
275488
|
};
|
|
275239
275489
|
|
|
275240
275490
|
// src/common/turbo.ts
|
|
@@ -275416,7 +275666,9 @@ var TurboAuthenticatedClient = class extends TurboUnauthenticatedClient {
|
|
|
275416
275666
|
events,
|
|
275417
275667
|
chunkByteCount,
|
|
275418
275668
|
chunkingMode,
|
|
275419
|
-
maxChunkConcurrency
|
|
275669
|
+
maxChunkConcurrency,
|
|
275670
|
+
maxFinalizeMs,
|
|
275671
|
+
fundingMode
|
|
275420
275672
|
}) {
|
|
275421
275673
|
return this.uploadService.upload({
|
|
275422
275674
|
data,
|
|
@@ -275425,7 +275677,9 @@ var TurboAuthenticatedClient = class extends TurboUnauthenticatedClient {
|
|
|
275425
275677
|
events,
|
|
275426
275678
|
chunkByteCount,
|
|
275427
275679
|
chunkingMode,
|
|
275428
|
-
maxChunkConcurrency
|
|
275680
|
+
maxChunkConcurrency,
|
|
275681
|
+
fundingMode,
|
|
275682
|
+
maxFinalizeMs
|
|
275429
275683
|
});
|
|
275430
275684
|
}
|
|
275431
275685
|
uploadFile(params) {
|
|
@@ -275565,7 +275819,8 @@ var TurboBaseFactory = class {
|
|
|
275565
275819
|
...uploadServiceConfig,
|
|
275566
275820
|
signer: turboSigner,
|
|
275567
275821
|
logger: logger19,
|
|
275568
|
-
token
|
|
275822
|
+
token,
|
|
275823
|
+
paymentService
|
|
275569
275824
|
});
|
|
275570
275825
|
return new TurboAuthenticatedClient({
|
|
275571
275826
|
uploadService,
|
|
@@ -275675,6 +275930,27 @@ var TurboDataItemAbstractSigner = class {
|
|
|
275675
275930
|
gatewayUrl
|
|
275676
275931
|
}) {
|
|
275677
275932
|
if (this.walletAdapter) {
|
|
275933
|
+
if (isSolanaWalletAdapter(this.walletAdapter)) {
|
|
275934
|
+
const connection = new Connection(gatewayUrl, "confirmed");
|
|
275935
|
+
const publicKey2 = new PublicKey(
|
|
275936
|
+
this.walletAdapter.publicKey?.toString?.() || // For backwards compatibility with umi uploader
|
|
275937
|
+
this.walletAdapter.publicKey?.toBuffer?.() || "<unknown>"
|
|
275938
|
+
);
|
|
275939
|
+
const tx2 = new Transaction2({
|
|
275940
|
+
feePayer: publicKey2,
|
|
275941
|
+
...await connection.getLatestBlockhash()
|
|
275942
|
+
});
|
|
275943
|
+
tx2.add(
|
|
275944
|
+
SystemProgram.transfer({
|
|
275945
|
+
fromPubkey: publicKey2,
|
|
275946
|
+
toPubkey: new PublicKey(target),
|
|
275947
|
+
lamports: +new BigNumber2(amount)
|
|
275948
|
+
})
|
|
275949
|
+
);
|
|
275950
|
+
const signedTx = await this.walletAdapter.signTransaction(tx2);
|
|
275951
|
+
const id3 = await connection.sendRawTransaction(signedTx.serialize());
|
|
275952
|
+
return id3;
|
|
275953
|
+
}
|
|
275678
275954
|
if (!isEthereumWalletAdapter(this.walletAdapter)) {
|
|
275679
275955
|
throw new Error(
|
|
275680
275956
|
"Unsupported wallet adapter -- must implement getSigner"
|
|
@@ -275978,9 +276254,10 @@ var TurboAuthenticatedUploadService = class extends TurboAuthenticatedBaseUpload
|
|
|
275978
276254
|
retryConfig,
|
|
275979
276255
|
signer,
|
|
275980
276256
|
logger: logger19,
|
|
275981
|
-
token
|
|
276257
|
+
token,
|
|
276258
|
+
paymentService
|
|
275982
276259
|
}) {
|
|
275983
|
-
super({ url, retryConfig, logger: logger19, token, signer });
|
|
276260
|
+
super({ url, retryConfig, logger: logger19, token, signer, paymentService });
|
|
275984
276261
|
}
|
|
275985
276262
|
getFiles(params) {
|
|
275986
276263
|
if (!isWebUploadFolderParams(params)) {
|
|
@@ -276066,77 +276343,6 @@ var TurboFactory = class _TurboFactory extends TurboBaseFactory {
|
|
|
276066
276343
|
});
|
|
276067
276344
|
}
|
|
276068
276345
|
};
|
|
276069
|
-
|
|
276070
|
-
// src/common/index.ts
|
|
276071
|
-
init_dirname();
|
|
276072
|
-
init_buffer2();
|
|
276073
|
-
init_process2();
|
|
276074
|
-
|
|
276075
|
-
// src/common/currency.ts
|
|
276076
|
-
init_dirname();
|
|
276077
|
-
init_buffer2();
|
|
276078
|
-
init_process2();
|
|
276079
|
-
var ZeroDecimalCurrency = class {
|
|
276080
|
-
constructor(amt, type4) {
|
|
276081
|
-
this.amt = amt;
|
|
276082
|
-
this.type = type4;
|
|
276083
|
-
if (amt < 0) {
|
|
276084
|
-
throw new ProvidedInputError(
|
|
276085
|
-
`${type4} currency amount cannot be negative`
|
|
276086
|
-
);
|
|
276087
|
-
}
|
|
276088
|
-
this.assertDecimalPlaces(amt);
|
|
276089
|
-
}
|
|
276090
|
-
assertDecimalPlaces(a8) {
|
|
276091
|
-
if (a8 % 1 !== 0) {
|
|
276092
|
-
throw new ProvidedInputError(
|
|
276093
|
-
`${this.type} currency amount must have zero decimal places`
|
|
276094
|
-
);
|
|
276095
|
-
}
|
|
276096
|
-
}
|
|
276097
|
-
get amount() {
|
|
276098
|
-
return this.amt;
|
|
276099
|
-
}
|
|
276100
|
-
};
|
|
276101
|
-
var TwoDecimalCurrency = class extends ZeroDecimalCurrency {
|
|
276102
|
-
constructor(a8, type4) {
|
|
276103
|
-
super(a8, type4);
|
|
276104
|
-
this.a = a8;
|
|
276105
|
-
this.type = type4;
|
|
276106
|
-
}
|
|
276107
|
-
assertDecimalPlaces(a8) {
|
|
276108
|
-
if (a8 * 100 % 1 !== 0) {
|
|
276109
|
-
throw new ProvidedInputError(
|
|
276110
|
-
`${this.type} currency amount must have two decimal places`
|
|
276111
|
-
);
|
|
276112
|
-
}
|
|
276113
|
-
}
|
|
276114
|
-
get amount() {
|
|
276115
|
-
return this.a * 100;
|
|
276116
|
-
}
|
|
276117
|
-
};
|
|
276118
|
-
var USD = (usd) => new TwoDecimalCurrency(usd, "usd");
|
|
276119
|
-
var EUR = (eur) => new TwoDecimalCurrency(eur, "eur");
|
|
276120
|
-
var GBP = (gbp) => new TwoDecimalCurrency(gbp, "gbp");
|
|
276121
|
-
var CAD = (cad) => new TwoDecimalCurrency(cad, "cad");
|
|
276122
|
-
var AUD = (aud) => new TwoDecimalCurrency(aud, "aud");
|
|
276123
|
-
var INR = (inr) => new TwoDecimalCurrency(inr, "inr");
|
|
276124
|
-
var SGD = (sgd) => new TwoDecimalCurrency(sgd, "sgd");
|
|
276125
|
-
var HKD = (hkd) => new TwoDecimalCurrency(hkd, "hkd");
|
|
276126
|
-
var BRL = (brl) => new TwoDecimalCurrency(brl, "brl");
|
|
276127
|
-
var JPY = (jpy) => new ZeroDecimalCurrency(jpy, "jpy");
|
|
276128
|
-
var currencyMap = {
|
|
276129
|
-
usd: USD,
|
|
276130
|
-
eur: EUR,
|
|
276131
|
-
gbp: GBP,
|
|
276132
|
-
cad: CAD,
|
|
276133
|
-
aud: AUD,
|
|
276134
|
-
inr: INR,
|
|
276135
|
-
sgd: SGD,
|
|
276136
|
-
hkd: HKD,
|
|
276137
|
-
brl: BRL,
|
|
276138
|
-
jpy: JPY
|
|
276139
|
-
};
|
|
276140
276346
|
export {
|
|
276141
276347
|
ARIOToTokenAmount,
|
|
276142
276348
|
ARIOToken,
|
|
@@ -276152,6 +276358,7 @@ export {
|
|
|
276152
276358
|
EUR,
|
|
276153
276359
|
EthereumSigner,
|
|
276154
276360
|
EthereumToken,
|
|
276361
|
+
ExistingBalanceFunding,
|
|
276155
276362
|
GBP,
|
|
276156
276363
|
HKD,
|
|
276157
276364
|
HexSolanaSigner2 as HexSolanaSigner,
|
|
@@ -276159,6 +276366,7 @@ export {
|
|
|
276159
276366
|
JPY,
|
|
276160
276367
|
KYVEToTokenAmount,
|
|
276161
276368
|
KyveToken,
|
|
276369
|
+
OnDemandFunding,
|
|
276162
276370
|
POLToTokenAmount,
|
|
276163
276371
|
PolygonToken,
|
|
276164
276372
|
SGD,
|