@ardrive/turbo-sdk 1.20.2 → 1.21.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.
- package/README.md +29 -0
- package/bundles/web.bundle.min.js +312 -277
- package/lib/cjs/cli/cli.js +6 -0
- package/lib/cjs/cli/commands/shareCredits.js +1 -1
- package/lib/cjs/cli/commands/tokenPrice.js +45 -0
- package/lib/cjs/cli/options.js +4 -0
- package/lib/cjs/common/payment.js +15 -0
- package/lib/cjs/common/signer.js +3 -3
- package/lib/cjs/common/token/index.js +9 -1
- package/lib/cjs/common/turbo.js +6 -0
- package/lib/cjs/utils/base64.js +2 -2
- package/lib/cjs/utils/common.js +1 -0
- package/lib/cjs/version.js +1 -1
- package/lib/esm/cli/cli.js +6 -0
- package/lib/esm/cli/commands/shareCredits.js +1 -1
- package/lib/esm/cli/commands/tokenPrice.js +42 -0
- package/lib/esm/cli/options.js +4 -0
- package/lib/esm/common/payment.js +15 -0
- package/lib/esm/common/signer.js +3 -3
- package/lib/esm/common/token/index.js +8 -0
- package/lib/esm/common/turbo.js +6 -0
- package/lib/esm/utils/base64.js +2 -2
- package/lib/esm/utils/common.js +1 -0
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/commands/shareCredits.d.ts.map +1 -1
- package/lib/types/cli/commands/tokenPrice.d.ts +3 -0
- package/lib/types/cli/commands/tokenPrice.d.ts.map +1 -0
- package/lib/types/cli/options.d.ts +4 -0
- package/lib/types/cli/options.d.ts.map +1 -1
- package/lib/types/cli/types.d.ts +6 -3
- package/lib/types/cli/types.d.ts.map +1 -1
- package/lib/types/common/payment.d.ts +4 -1
- package/lib/types/common/payment.d.ts.map +1 -1
- package/lib/types/common/signer.d.ts.map +1 -1
- package/lib/types/common/token/index.d.ts +1 -0
- package/lib/types/common/token/index.d.ts.map +1 -1
- package/lib/types/common/turbo.d.ts +7 -1
- package/lib/types/common/turbo.d.ts.map +1 -1
- package/lib/types/types.d.ts +8 -0
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/utils/common.d.ts.map +1 -1
- package/lib/types/version.d.ts +1 -1
- package/lib/types/version.d.ts.map +1 -1
- package/package.json +1 -1
@@ -0,0 +1,45 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.tokenPrice = tokenPrice;
|
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 index_js_1 = require("../../common/index.js");
|
20
|
+
const factory_js_1 = require("../../node/factory.js");
|
21
|
+
const types_js_1 = require("../../types.js");
|
22
|
+
const utils_js_1 = require("../utils.js");
|
23
|
+
async function tokenPrice(options) {
|
24
|
+
const byteCount = options.byteCount !== undefined ? +options.byteCount : undefined;
|
25
|
+
if (byteCount === undefined ||
|
26
|
+
byteCount <= 0 ||
|
27
|
+
isNaN(byteCount) ||
|
28
|
+
!Number.isInteger(byteCount)) {
|
29
|
+
throw new Error('Must provide a positive number for byte to get price.\nFor example, to get the SOL price for 100 MiB use the following:\nturbo token-price --token solana --byte-count 1048576000');
|
30
|
+
}
|
31
|
+
const token = options.token;
|
32
|
+
if (!(0, index_js_1.isTokenType)(token)) {
|
33
|
+
throw new Error(`Invalid token type ${token}. Must be one of ${types_js_1.tokenTypes.join(', ')}`);
|
34
|
+
}
|
35
|
+
const turbo = factory_js_1.TurboFactory.unauthenticated((0, utils_js_1.configFromOptions)(options));
|
36
|
+
const { tokenPrice } = await turbo.getTokenPriceForBytes({
|
37
|
+
byteCount: +byteCount,
|
38
|
+
});
|
39
|
+
const output = {
|
40
|
+
tokenPrice,
|
41
|
+
byteCount,
|
42
|
+
message: `The current price estimate for ${byteCount} bytes is ${tokenPrice} ${token}`,
|
43
|
+
};
|
44
|
+
console.log(JSON.stringify(output, null, 2));
|
45
|
+
}
|
package/lib/cjs/cli/options.js
CHANGED
@@ -142,6 +142,10 @@ exports.optionMap = {
|
|
142
142
|
description: 'Use the signer balance first before using credit share approvals',
|
143
143
|
default: false,
|
144
144
|
},
|
145
|
+
byteCount: {
|
146
|
+
alias: '--byte-count <byteCount>',
|
147
|
+
description: 'Number of bytes to use for the action',
|
148
|
+
},
|
145
149
|
};
|
146
150
|
exports.walletOptions = [
|
147
151
|
exports.optionMap.walletFile,
|
@@ -20,6 +20,7 @@ const bignumber_js_1 = require("bignumber.js");
|
|
20
20
|
const node_buffer_1 = require("node:buffer");
|
21
21
|
const http_js_1 = require("./http.js");
|
22
22
|
const logger_js_1 = require("./logger.js");
|
23
|
+
const index_js_1 = require("./token/index.js");
|
23
24
|
exports.developmentPaymentServiceURL = 'https://payment.ardrive.dev';
|
24
25
|
exports.defaultPaymentServiceURL = 'https://payment.ardrive.io';
|
25
26
|
class TurboUnauthenticatedPaymentService {
|
@@ -178,6 +179,20 @@ class TurboUnauthenticatedPaymentService {
|
|
178
179
|
}
|
179
180
|
return response;
|
180
181
|
}
|
182
|
+
async getTokenPriceForBytes({ byteCount, }) {
|
183
|
+
const wincPriceForOneToken = (await this.getWincForToken({
|
184
|
+
tokenAmount: index_js_1.tokenToBaseMap[this.token](1),
|
185
|
+
})).winc;
|
186
|
+
const wincPriceForOneGiB = (await this.getUploadCosts({
|
187
|
+
bytes: [2 ** 30],
|
188
|
+
}))[0].winc;
|
189
|
+
const tokenPriceForOneGiB = new bignumber_js_1.BigNumber(wincPriceForOneGiB).dividedBy(wincPriceForOneToken);
|
190
|
+
const tokenPriceForBytes = tokenPriceForOneGiB
|
191
|
+
.dividedBy(2 ** 30)
|
192
|
+
.times(byteCount)
|
193
|
+
.toFixed(index_js_1.exponentMap[this.token]);
|
194
|
+
return { byteCount, tokenPrice: tokenPriceForBytes, token: this.token };
|
195
|
+
}
|
181
196
|
}
|
182
197
|
exports.TurboUnauthenticatedPaymentService = TurboUnauthenticatedPaymentService;
|
183
198
|
// NOTE: to avoid redundancy, we use inheritance here - but generally prefer composition over inheritance
|
package/lib/cjs/common/signer.js
CHANGED
@@ -47,7 +47,7 @@ class TurboDataItemAbstractSigner {
|
|
47
47
|
ownerToNativeAddress(owner, token) {
|
48
48
|
switch (token) {
|
49
49
|
case 'solana':
|
50
|
-
return bs58_1.default.encode((0, base64_js_1.fromB64Url)(owner));
|
50
|
+
return bs58_1.default.encode(Uint8Array.from((0, base64_js_1.fromB64Url)(owner)));
|
51
51
|
case 'ethereum':
|
52
52
|
case 'matic':
|
53
53
|
case 'pol':
|
@@ -55,7 +55,7 @@ class TurboDataItemAbstractSigner {
|
|
55
55
|
case 'kyve':
|
56
56
|
return (0, amino_1.pubkeyToAddress)({
|
57
57
|
type: 'tendermint/PubKeySecp256k1',
|
58
|
-
value: (0, encoding_1.toBase64)(crypto_1.Secp256k1.compressPubkey((0, base64_js_1.fromB64Url)(owner))),
|
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
61
|
default:
|
@@ -65,7 +65,7 @@ class TurboDataItemAbstractSigner {
|
|
65
65
|
async generateSignedRequestHeaders() {
|
66
66
|
const nonce = (0, crypto_2.randomBytes)(16).toString('hex');
|
67
67
|
const buffer = node_buffer_1.Buffer.from(nonce);
|
68
|
-
const signature = await this.signer.sign(buffer);
|
68
|
+
const signature = await this.signer.sign(Uint8Array.from(buffer));
|
69
69
|
const publicKey = (0, base64_js_1.toB64Url)(this.signer.publicKey);
|
70
70
|
return {
|
71
71
|
'x-public-key': publicKey,
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
15
|
};
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
exports.tokenToBaseMap = exports.defaultTokenMap = void 0;
|
17
|
+
exports.tokenToBaseMap = exports.exponentMap = exports.defaultTokenMap = void 0;
|
18
18
|
exports.isTokenType = isTokenType;
|
19
19
|
const types_js_1 = require("../../types.js");
|
20
20
|
const arweave_js_1 = require("./arweave.js");
|
@@ -30,6 +30,14 @@ exports.defaultTokenMap = {
|
|
30
30
|
matic: (config) => new polygon_js_1.PolygonToken(config),
|
31
31
|
pol: (config) => new polygon_js_1.PolygonToken(config),
|
32
32
|
};
|
33
|
+
exports.exponentMap = {
|
34
|
+
arweave: 12,
|
35
|
+
solana: 9,
|
36
|
+
ethereum: 18,
|
37
|
+
kyve: 6,
|
38
|
+
matic: 18,
|
39
|
+
pol: 18,
|
40
|
+
};
|
33
41
|
exports.tokenToBaseMap = {
|
34
42
|
arweave: (a) => (0, arweave_js_1.ARToTokenAmount)(a),
|
35
43
|
solana: (a) => (0, solana_js_1.SOLToTokenAmount)(a),
|
package/lib/cjs/common/turbo.js
CHANGED
@@ -78,6 +78,12 @@ class TurboUnauthenticatedClient {
|
|
78
78
|
getWincForToken(params) {
|
79
79
|
return this.paymentService.getWincForToken(params);
|
80
80
|
}
|
81
|
+
/**
|
82
|
+
* Determines the price in the instantiated token to upload one data item of a specific size in bytes, including all Turbo cost adjustments and fees.
|
83
|
+
*/
|
84
|
+
getTokenPriceForBytes({ byteCount, }) {
|
85
|
+
return this.paymentService.getTokenPriceForBytes({ byteCount });
|
86
|
+
}
|
81
87
|
/**
|
82
88
|
* Uploads a signed data item to the Turbo Upload Service.
|
83
89
|
*/
|
package/lib/cjs/utils/base64.js
CHANGED
@@ -40,8 +40,8 @@ function fromB64Url(input) {
|
|
40
40
|
return node_buffer_1.Buffer.from(base64, 'base64');
|
41
41
|
}
|
42
42
|
function toB64Url(buffer) {
|
43
|
-
return (0, utils_js_1.bufferTob64Url)(buffer);
|
43
|
+
return (0, utils_js_1.bufferTob64Url)(Uint8Array.from(buffer));
|
44
44
|
}
|
45
45
|
function sha256B64Url(input) {
|
46
|
-
return toB64Url((0, crypto_1.createHash)('sha256').update(input).digest());
|
46
|
+
return toB64Url((0, crypto_1.createHash)('sha256').update(Uint8Array.from(input)).digest());
|
47
47
|
}
|
package/lib/cjs/utils/common.js
CHANGED
@@ -42,6 +42,7 @@ function createTurboSigner({ signer: clientProvidedSigner, privateKey: clientPro
|
|
42
42
|
case 'solana':
|
43
43
|
return new arbundles_1.HexSolanaSigner(clientProvidedPrivateKey);
|
44
44
|
case 'ethereum':
|
45
|
+
case 'pol':
|
45
46
|
case 'matic':
|
46
47
|
if (!(0, types_js_1.isEthPrivateKey)(clientProvidedPrivateKey)) {
|
47
48
|
throw new Error('A valid Ethereum private key must be provided for EthereumSigner.');
|
package/lib/cjs/version.js
CHANGED
package/lib/esm/cli/cli.js
CHANGED
@@ -22,6 +22,7 @@ import { balance, cryptoFund, price, topUp, uploadFile, uploadFolder, } from './
|
|
22
22
|
import { listShares } from './commands/listShares.js';
|
23
23
|
import { revokeCredits } from './commands/revokeCredits.js';
|
24
24
|
import { shareCredits } from './commands/shareCredits.js';
|
25
|
+
import { tokenPrice } from './commands/tokenPrice.js';
|
25
26
|
import { globalOptions, listSharesOptions, optionMap, revokeCreditsOptions, shareCreditsOptions, uploadFileOptions, uploadFolderOptions, walletOptions, } from './options.js';
|
26
27
|
import { applyOptions, runCommand } from './utils.js';
|
27
28
|
applyOptions(program
|
@@ -49,6 +50,11 @@ applyOptions(program
|
|
49
50
|
.description('Get the current Credits estimate for byte, crypto, or fiat value'), [optionMap.value, optionMap.type]).action(async (_commandOptions, command) => {
|
50
51
|
await runCommand(command, price);
|
51
52
|
});
|
53
|
+
applyOptions(program
|
54
|
+
.command('token-price')
|
55
|
+
.description('Get the current token price for provided byte value'), [optionMap.byteCount]).action(async (_commandOptions, command) => {
|
56
|
+
await runCommand(command, tokenPrice);
|
57
|
+
});
|
52
58
|
applyOptions(program
|
53
59
|
.command('share-credits')
|
54
60
|
.description('Create a Turbo credit share approval'), shareCreditsOptions).action(async (_commandOptions, command) => {
|
@@ -30,7 +30,7 @@ export async function shareCredits(options) {
|
|
30
30
|
const result = await turbo.shareCredits({
|
31
31
|
approvedAddress,
|
32
32
|
approvedWincAmount,
|
33
|
-
expiresBySeconds,
|
33
|
+
expiresBySeconds: expiresBySeconds !== undefined ? +expiresBySeconds : undefined,
|
34
34
|
});
|
35
35
|
console.log(JSON.stringify({ message: 'Created credit share approval!', ...result }, null, 2));
|
36
36
|
}
|
@@ -0,0 +1,42 @@
|
|
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 { isTokenType } from '../../common/index.js';
|
17
|
+
import { TurboFactory } from '../../node/factory.js';
|
18
|
+
import { tokenTypes } from '../../types.js';
|
19
|
+
import { configFromOptions } from '../utils.js';
|
20
|
+
export async function tokenPrice(options) {
|
21
|
+
const byteCount = options.byteCount !== undefined ? +options.byteCount : undefined;
|
22
|
+
if (byteCount === undefined ||
|
23
|
+
byteCount <= 0 ||
|
24
|
+
isNaN(byteCount) ||
|
25
|
+
!Number.isInteger(byteCount)) {
|
26
|
+
throw new Error('Must provide a positive number for byte to get price.\nFor example, to get the SOL price for 100 MiB use the following:\nturbo token-price --token solana --byte-count 1048576000');
|
27
|
+
}
|
28
|
+
const token = options.token;
|
29
|
+
if (!isTokenType(token)) {
|
30
|
+
throw new Error(`Invalid token type ${token}. Must be one of ${tokenTypes.join(', ')}`);
|
31
|
+
}
|
32
|
+
const turbo = TurboFactory.unauthenticated(configFromOptions(options));
|
33
|
+
const { tokenPrice } = await turbo.getTokenPriceForBytes({
|
34
|
+
byteCount: +byteCount,
|
35
|
+
});
|
36
|
+
const output = {
|
37
|
+
tokenPrice,
|
38
|
+
byteCount,
|
39
|
+
message: `The current price estimate for ${byteCount} bytes is ${tokenPrice} ${token}`,
|
40
|
+
};
|
41
|
+
console.log(JSON.stringify(output, null, 2));
|
42
|
+
}
|
package/lib/esm/cli/options.js
CHANGED
@@ -139,6 +139,10 @@ export const optionMap = {
|
|
139
139
|
description: 'Use the signer balance first before using credit share approvals',
|
140
140
|
default: false,
|
141
141
|
},
|
142
|
+
byteCount: {
|
143
|
+
alias: '--byte-count <byteCount>',
|
144
|
+
description: 'Number of bytes to use for the action',
|
145
|
+
},
|
142
146
|
};
|
143
147
|
export const walletOptions = [
|
144
148
|
optionMap.walletFile,
|
@@ -17,6 +17,7 @@ import { BigNumber } from 'bignumber.js';
|
|
17
17
|
import { Buffer } from 'node:buffer';
|
18
18
|
import { TurboHTTPService } from './http.js';
|
19
19
|
import { TurboWinstonLogger } from './logger.js';
|
20
|
+
import { exponentMap, tokenToBaseMap } from './token/index.js';
|
20
21
|
export const developmentPaymentServiceURL = 'https://payment.ardrive.dev';
|
21
22
|
export const defaultPaymentServiceURL = 'https://payment.ardrive.io';
|
22
23
|
export class TurboUnauthenticatedPaymentService {
|
@@ -175,6 +176,20 @@ export class TurboUnauthenticatedPaymentService {
|
|
175
176
|
}
|
176
177
|
return response;
|
177
178
|
}
|
179
|
+
async getTokenPriceForBytes({ byteCount, }) {
|
180
|
+
const wincPriceForOneToken = (await this.getWincForToken({
|
181
|
+
tokenAmount: tokenToBaseMap[this.token](1),
|
182
|
+
})).winc;
|
183
|
+
const wincPriceForOneGiB = (await this.getUploadCosts({
|
184
|
+
bytes: [2 ** 30],
|
185
|
+
}))[0].winc;
|
186
|
+
const tokenPriceForOneGiB = new BigNumber(wincPriceForOneGiB).dividedBy(wincPriceForOneToken);
|
187
|
+
const tokenPriceForBytes = tokenPriceForOneGiB
|
188
|
+
.dividedBy(2 ** 30)
|
189
|
+
.times(byteCount)
|
190
|
+
.toFixed(exponentMap[this.token]);
|
191
|
+
return { byteCount, tokenPrice: tokenPriceForBytes, token: this.token };
|
192
|
+
}
|
178
193
|
}
|
179
194
|
// NOTE: to avoid redundancy, we use inheritance here - but generally prefer composition over inheritance
|
180
195
|
export class TurboAuthenticatedPaymentService extends TurboUnauthenticatedPaymentService {
|
package/lib/esm/common/signer.js
CHANGED
@@ -41,7 +41,7 @@ export class TurboDataItemAbstractSigner {
|
|
41
41
|
ownerToNativeAddress(owner, token) {
|
42
42
|
switch (token) {
|
43
43
|
case 'solana':
|
44
|
-
return bs58.encode(fromB64Url(owner));
|
44
|
+
return bs58.encode(Uint8Array.from(fromB64Url(owner)));
|
45
45
|
case 'ethereum':
|
46
46
|
case 'matic':
|
47
47
|
case 'pol':
|
@@ -49,7 +49,7 @@ export class TurboDataItemAbstractSigner {
|
|
49
49
|
case 'kyve':
|
50
50
|
return pubkeyToAddress({
|
51
51
|
type: 'tendermint/PubKeySecp256k1',
|
52
|
-
value: toBase64(Secp256k1.compressPubkey(fromB64Url(owner))),
|
52
|
+
value: toBase64(Secp256k1.compressPubkey(Uint8Array.from(fromB64Url(owner)))),
|
53
53
|
}, 'kyve');
|
54
54
|
case 'arweave':
|
55
55
|
default:
|
@@ -59,7 +59,7 @@ export class TurboDataItemAbstractSigner {
|
|
59
59
|
async generateSignedRequestHeaders() {
|
60
60
|
const nonce = randomBytes(16).toString('hex');
|
61
61
|
const buffer = Buffer.from(nonce);
|
62
|
-
const signature = await this.signer.sign(buffer);
|
62
|
+
const signature = await this.signer.sign(Uint8Array.from(buffer));
|
63
63
|
const publicKey = toB64Url(this.signer.publicKey);
|
64
64
|
return {
|
65
65
|
'x-public-key': publicKey,
|
@@ -12,6 +12,14 @@ export const defaultTokenMap = {
|
|
12
12
|
matic: (config) => new PolygonToken(config),
|
13
13
|
pol: (config) => new PolygonToken(config),
|
14
14
|
};
|
15
|
+
export const exponentMap = {
|
16
|
+
arweave: 12,
|
17
|
+
solana: 9,
|
18
|
+
ethereum: 18,
|
19
|
+
kyve: 6,
|
20
|
+
matic: 18,
|
21
|
+
pol: 18,
|
22
|
+
};
|
15
23
|
export const tokenToBaseMap = {
|
16
24
|
arweave: (a) => ARToTokenAmount(a),
|
17
25
|
solana: (a) => SOLToTokenAmount(a),
|
package/lib/esm/common/turbo.js
CHANGED
@@ -75,6 +75,12 @@ export class TurboUnauthenticatedClient {
|
|
75
75
|
getWincForToken(params) {
|
76
76
|
return this.paymentService.getWincForToken(params);
|
77
77
|
}
|
78
|
+
/**
|
79
|
+
* Determines the price in the instantiated token to upload one data item of a specific size in bytes, including all Turbo cost adjustments and fees.
|
80
|
+
*/
|
81
|
+
getTokenPriceForBytes({ byteCount, }) {
|
82
|
+
return this.paymentService.getTokenPriceForBytes({ byteCount });
|
83
|
+
}
|
78
84
|
/**
|
79
85
|
* Uploads a signed data item to the Turbo Upload Service.
|
80
86
|
*/
|
package/lib/esm/utils/base64.js
CHANGED
@@ -32,8 +32,8 @@ export function fromB64Url(input) {
|
|
32
32
|
return Buffer.from(base64, 'base64');
|
33
33
|
}
|
34
34
|
export function toB64Url(buffer) {
|
35
|
-
return bufferTob64Url(buffer);
|
35
|
+
return bufferTob64Url(Uint8Array.from(buffer));
|
36
36
|
}
|
37
37
|
export function sha256B64Url(input) {
|
38
|
-
return toB64Url(createHash('sha256').update(input).digest());
|
38
|
+
return toB64Url(createHash('sha256').update(Uint8Array.from(input)).digest());
|
39
39
|
}
|
package/lib/esm/utils/common.js
CHANGED
@@ -35,6 +35,7 @@ export function createTurboSigner({ signer: clientProvidedSigner, privateKey: cl
|
|
35
35
|
case 'solana':
|
36
36
|
return new HexSolanaSigner(clientProvidedPrivateKey);
|
37
37
|
case 'ethereum':
|
38
|
+
case 'pol':
|
38
39
|
case 'matic':
|
39
40
|
if (!isEthPrivateKey(clientProvidedPrivateKey)) {
|
40
41
|
throw new Error('A valid Ethereum private key must be provided for EthereumSigner.');
|
package/lib/esm/version.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"shareCredits.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/shareCredits.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGlD,wBAAsB,YAAY,CAChC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,IAAI,CAAC,
|
1
|
+
{"version":3,"file":"shareCredits.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/shareCredits.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGlD,wBAAsB,YAAY,CAChC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAkCf"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"tokenPrice.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/tokenPrice.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,wBAAsB,UAAU,CAAC,OAAO,EAAE,iBAAiB,iBAgC1D"}
|
@@ -137,6 +137,10 @@ export declare const optionMap: {
|
|
137
137
|
readonly description: "Use the signer balance first before using credit share approvals";
|
138
138
|
readonly default: false;
|
139
139
|
};
|
140
|
+
readonly byteCount: {
|
141
|
+
readonly alias: "--byte-count <byteCount>";
|
142
|
+
readonly description: "Number of bytes to use for the action";
|
143
|
+
};
|
140
144
|
};
|
141
145
|
export declare const walletOptions: ({
|
142
146
|
readonly alias: "-w, --wallet-file <filePath>";
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/cli/options.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,eAAO,MAAM,SAAS
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/cli/options.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwIZ,CAAC;AAEX,eAAO,MAAM,aAAa;;;;;;;;;IAIzB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAUzB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;IAKzB,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAO/B,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;IAAyC,CAAC;AAExE,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;IAK/B,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;IAAwC,CAAC;AAE1E,eAAO,MAAM,iBAAiB;;;;;;;;;;;;IAAuB,CAAC"}
|
package/lib/types/cli/types.d.ts
CHANGED
@@ -46,12 +46,15 @@ export type UploadFolderOptions = UploadOptions & {
|
|
46
46
|
indexFile: string | undefined;
|
47
47
|
fallbackFile: string | undefined;
|
48
48
|
manifest: boolean;
|
49
|
-
maxConcurrency:
|
49
|
+
maxConcurrency: string | undefined;
|
50
50
|
};
|
51
51
|
export type UploadFileOptions = UploadOptions & {
|
52
52
|
filePath: string | undefined;
|
53
53
|
};
|
54
|
-
export type
|
54
|
+
export type TokenPriceOptions = GlobalOptions & {
|
55
|
+
byteCount: string | undefined;
|
56
|
+
};
|
57
|
+
export type PriceOptions = TokenPriceOptions & {
|
55
58
|
value: string | undefined;
|
56
59
|
type: string | undefined;
|
57
60
|
};
|
@@ -62,7 +65,7 @@ export type CryptoFundOptions = WalletOptions & {
|
|
62
65
|
export type ShareCreditsOptions = WalletOptions & {
|
63
66
|
address: string | undefined;
|
64
67
|
value: string | undefined;
|
65
|
-
expiresBySeconds:
|
68
|
+
expiresBySeconds: string | undefined;
|
66
69
|
};
|
67
70
|
export type RevokeCreditsOptions = WalletOptions & {
|
68
71
|
address: string | undefined;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/cli/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,MAAM,aAAa,GAAG;IAC1B,GAAG,EAAE,OAAO,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,gBAAgB,EAAE,OAAO,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,aAAa,GAAG;IAC1C,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,CAAC;AAEF,M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AAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,aAAa,GAAG;IAChD,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAAG;IACjD,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,oBAAoB,CAAC"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Currency, GetCreditShareApprovalsResponse, TokenTools, TokenType, TurboAuthenticatedPaymentServiceConfiguration, TurboAuthenticatedPaymentServiceInterface, TurboBalanceResponse, TurboCheckoutSessionParams, TurboCheckoutSessionResponse, TurboCountriesResponse, TurboCryptoFundResponse, TurboCurrenciesResponse, TurboDataItemSigner, TurboFiatToArResponse, TurboFundWithTokensParams, TurboLogger, TurboPriceResponse, TurboRatesResponse, TurboSignedRequestHeaders, TurboSubmitFundTxResponse, TurboUnauthenticatedPaymentServiceConfiguration, TurboUnauthenticatedPaymentServiceInterface, TurboWincForFiatParams, TurboWincForFiatResponse, TurboWincForTokenParams, TurboWincForTokenResponse, UserAddress } from '../types.js';
|
1
|
+
import { Currency, GetCreditShareApprovalsResponse, TokenTools, TokenType, TurboAuthenticatedPaymentServiceConfiguration, TurboAuthenticatedPaymentServiceInterface, TurboBalanceResponse, TurboCheckoutSessionParams, TurboCheckoutSessionResponse, TurboCountriesResponse, TurboCryptoFundResponse, TurboCurrenciesResponse, TurboDataItemSigner, TurboFiatToArResponse, TurboFundWithTokensParams, TurboLogger, TurboPriceResponse, TurboRatesResponse, TurboSignedRequestHeaders, TurboSubmitFundTxResponse, TurboTokenPriceForBytesResponse, TurboUnauthenticatedPaymentServiceConfiguration, TurboUnauthenticatedPaymentServiceInterface, TurboWincForFiatParams, TurboWincForFiatResponse, TurboWincForTokenParams, TurboWincForTokenResponse, UserAddress } from '../types.js';
|
2
2
|
import { TurboHTTPService } from './http.js';
|
3
3
|
export declare const developmentPaymentServiceURL = "https://payment.ardrive.dev";
|
4
4
|
export declare const defaultPaymentServiceURL = "https://payment.ardrive.io";
|
@@ -29,6 +29,9 @@ export declare class TurboUnauthenticatedPaymentService implements TurboUnauthen
|
|
29
29
|
getCreditShareApprovals({ userAddress, }: {
|
30
30
|
userAddress: UserAddress;
|
31
31
|
}): Promise<GetCreditShareApprovalsResponse>;
|
32
|
+
getTokenPriceForBytes({ byteCount, }: {
|
33
|
+
byteCount: number;
|
34
|
+
}): Promise<TurboTokenPriceForBytesResponse>;
|
32
35
|
}
|
33
36
|
export declare class TurboAuthenticatedPaymentService extends TurboUnauthenticatedPaymentService implements TurboAuthenticatedPaymentServiceInterface {
|
34
37
|
protected readonly signer: TurboDataItemSigner;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["../../../src/common/payment.ts"],"names":[],"mappings":"AAkBA,OAAO,EACL,QAAQ,EACR,+BAA+B,EAE/B,UAAU,EACV,SAAS,EAET,6CAA6C,EAC7C,yCAAyC,EACzC,oBAAoB,EACpB,0BAA0B,EAC1B,4BAA4B,EAC5B,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,qBAAqB,EACrB,yBAAyB,EAEzB,WAAW,EAEX,kBAAkB,EAClB,kBAAkB,EAClB,yBAAyB,EACzB,yBAAyB,EACzB,+CAA+C,EAC/C,2CAA2C,EAC3C,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,EACvB,yBAAyB,EACzB,WAAW,EACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;
|
1
|
+
{"version":3,"file":"payment.d.ts","sourceRoot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+16,7 @@
|
|
16
16
|
import { BigNumber } from 'bignumber.js';
|
17
17
|
import { TokenFactory, TokenType } from '../../types.js';
|
18
18
|
export declare const defaultTokenMap: TokenFactory;
|
19
|
+
export declare const exponentMap: Record<TokenType, number>;
|
19
20
|
export declare const tokenToBaseMap: Record<TokenType, (a: BigNumber.Value) => BigNumber.Value>;
|
20
21
|
export declare function isTokenType(token: string): token is TokenType;
|
21
22
|
export * from './arweave.js';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/common/token/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAEL,YAAY,EACZ,SAAS,EAEV,MAAM,gBAAgB,CAAC;AAOxB,eAAO,MAAM,eAAe,EAAE,YAOpB,CAAC;AAEX,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,SAAS,EACT,CAAC,CAAC,EAAE,SAAS,CAAC,KAAK,KAAK,SAAS,CAAC,KAAK,CAQ/B,CAAC;AAEX,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,SAAS,CAE7D;AAED,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/common/token/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAEL,YAAY,EACZ,SAAS,EAEV,MAAM,gBAAgB,CAAC;AAOxB,eAAO,MAAM,eAAe,EAAE,YAOpB,CAAC;AAEX,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAOxC,CAAC;AAEX,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,SAAS,EACT,CAAC,CAAC,EAAE,SAAS,CAAC,KAAK,KAAK,SAAS,CAAC,KAAK,CAQ/B,CAAC;AAEX,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,SAAS,CAE7D;AAED,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC"}
|
@@ -13,7 +13,7 @@
|
|
13
13
|
* See the License for the specific language governing permissions and
|
14
14
|
* limitations under the License.
|
15
15
|
*/
|
16
|
-
import { CreditShareApproval, Currency, GetCreditShareApprovalsResponse, NativeAddress, TokenType, TurboAbortSignal, TurboAuthenticatedClientConfiguration, TurboAuthenticatedClientInterface, TurboAuthenticatedPaymentServiceInterface, TurboAuthenticatedUploadServiceInterface, TurboBalanceResponse, TurboCheckoutSessionParams, TurboCheckoutSessionResponse, TurboCountriesResponse, TurboCreateCreditShareApprovalParams, TurboCryptoFundResponse, TurboCurrenciesResponse, TurboDataItemSigner, TurboFiatToArResponse, TurboFileFactory, TurboFundWithTokensParams, TurboPriceResponse, TurboRatesResponse, TurboRevokeCreditsParams, TurboSignedDataItemFactory, TurboSubmitFundTxResponse, TurboUnauthenticatedClientConfiguration, TurboUnauthenticatedClientInterface, TurboUnauthenticatedPaymentServiceInterface, TurboUnauthenticatedUploadServiceInterface, TurboUploadDataItemResponse, TurboUploadFolderParams, TurboUploadFolderResponse, TurboWincForFiatParams, TurboWincForFiatResponse, TurboWincForTokenParams, TurboWincForTokenResponse } from '../types.js';
|
16
|
+
import { CreditShareApproval, Currency, GetCreditShareApprovalsResponse, NativeAddress, TokenType, TurboAbortSignal, TurboAuthenticatedClientConfiguration, TurboAuthenticatedClientInterface, TurboAuthenticatedPaymentServiceInterface, TurboAuthenticatedUploadServiceInterface, TurboBalanceResponse, TurboCheckoutSessionParams, TurboCheckoutSessionResponse, TurboCountriesResponse, TurboCreateCreditShareApprovalParams, TurboCryptoFundResponse, TurboCurrenciesResponse, TurboDataItemSigner, TurboFiatToArResponse, TurboFileFactory, TurboFundWithTokensParams, TurboPriceResponse, TurboRatesResponse, TurboRevokeCreditsParams, TurboSignedDataItemFactory, TurboSubmitFundTxResponse, TurboTokenPriceForBytesResponse, TurboUnauthenticatedClientConfiguration, TurboUnauthenticatedClientInterface, TurboUnauthenticatedPaymentServiceInterface, TurboUnauthenticatedUploadServiceInterface, TurboUploadDataItemResponse, TurboUploadFolderParams, TurboUploadFolderResponse, TurboWincForFiatParams, TurboWincForFiatResponse, TurboWincForTokenParams, TurboWincForTokenResponse } from '../types.js';
|
17
17
|
/**
|
18
18
|
* Testing configuration.
|
19
19
|
*/
|
@@ -76,6 +76,12 @@ export declare class TurboUnauthenticatedClient implements TurboUnauthenticatedC
|
|
76
76
|
* Determines the amount of 'winc' that would be returned for a given token and amount, including all Turbo cost adjustments and fees.
|
77
77
|
*/
|
78
78
|
getWincForToken(params: TurboWincForTokenParams): Promise<TurboWincForTokenResponse>;
|
79
|
+
/**
|
80
|
+
* Determines the price in the instantiated token to upload one data item of a specific size in bytes, including all Turbo cost adjustments and fees.
|
81
|
+
*/
|
82
|
+
getTokenPriceForBytes({ byteCount, }: {
|
83
|
+
byteCount: number;
|
84
|
+
}): Promise<TurboTokenPriceForBytesResponse>;
|
79
85
|
/**
|
80
86
|
* Uploads a signed data item to the Turbo Upload Service.
|
81
87
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"turbo.d.ts","sourceRoot":"","sources":["../../../src/common/turbo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EACL,mBAAmB,EACnB,QAAQ,EACR,+BAA+B,EAC/B,aAAa,EACb,SAAS,EACT,gBAAgB,EAChB,qCAAqC,EACrC,iCAAiC,EACjC,yCAAyC,EACzC,wCAAwC,EACxC,oBAAoB,EACpB,0BAA0B,EAC1B,4BAA4B,EAC5B,sBAAsB,EACtB,oCAAoC,EACpC,uBAA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ount: string;
|
63
63
|
equivalentWincTokenAmount: string;
|
64
64
|
};
|
65
|
+
export type TurboTokenPriceForBytesResponse = {
|
66
|
+
tokenPrice: string;
|
67
|
+
byteCount: number;
|
68
|
+
token: TokenType;
|
69
|
+
};
|
65
70
|
export type TurboWincForFiatParams = {
|
66
71
|
amount: CurrencyMap;
|
67
72
|
nativeAddress?: NativeAddress;
|
@@ -406,6 +411,9 @@ export interface TurboUnauthenticatedPaymentServiceInterface {
|
|
406
411
|
getFiatRates(): Promise<TurboRatesResponse>;
|
407
412
|
getWincForFiat(params: TurboWincForFiatParams): Promise<TurboWincForFiatResponse>;
|
408
413
|
getWincForToken(params: TurboWincForTokenParams): Promise<TurboWincForTokenResponse>;
|
414
|
+
getTokenPriceForBytes({ byteCount, }: {
|
415
|
+
byteCount: number;
|
416
|
+
}): Promise<TurboTokenPriceForBytesResponse>;
|
409
417
|
getUploadCosts({ bytes }: {
|
410
418
|
bytes: number[];
|
411
419
|
}): Promise<TurboPriceResponse[]>;
|