@alephium/web3 0.5.2 → 0.5.4

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.
@@ -3,7 +3,7 @@ import { SignDeployContractTxParams, SignDeployContractTxResult, SignExecuteScri
3
3
  export declare abstract class TransactionBuilder {
4
4
  abstract get nodeProvider(): NodeProvider;
5
5
  static from(nodeProvider: NodeProvider): TransactionBuilder;
6
- static from(baseUrl: string, apiKey?: string): TransactionBuilder;
6
+ static from(baseUrl: string, apiKey?: string, customFetch?: typeof fetch): TransactionBuilder;
7
7
  private static validatePublicKey;
8
8
  buildTransferTx(params: SignTransferTxParams, publicKey: string): Promise<Omit<SignTransferTxResult, 'signature'>>;
9
9
  buildDeployContractTx(params: SignDeployContractTxParams, publicKey: string): Promise<Omit<SignDeployContractTxResult, 'signature'>>;
@@ -23,8 +23,8 @@ const api_1 = require("../api");
23
23
  const utils_1 = require("../utils");
24
24
  const signer_1 = require("./signer");
25
25
  class TransactionBuilder {
26
- static from(param0, param1) {
27
- const nodeProvider = typeof param0 === 'string' ? new api_1.NodeProvider(param0, param1) : param0;
26
+ static from(param0, param1, customFetch) {
27
+ const nodeProvider = typeof param0 === 'string' ? new api_1.NodeProvider(param0, param1, customFetch) : param0;
28
28
  return new (class extends TransactionBuilder {
29
29
  get nodeProvider() {
30
30
  return nodeProvider;
@@ -14,5 +14,5 @@ export declare function prettifyTokenAmount(amount: Number256, decimals: number)
14
14
  export declare function prettifyExactAmount(amount: Number256, decimals: number): string | undefined;
15
15
  export declare function prettifyNumber(amount: Number256, decimals: number, config: IPrettifyNumberConfig): string | undefined;
16
16
  export declare function convertAmountWithDecimals(amount: string | number, decimals: number): bigint | undefined;
17
- export declare function convertAlphAmount(amount: string | number): bigint | undefined;
17
+ export declare function convertAlphAmountWithDecimals(amount: string | number): bigint | undefined;
18
18
  export declare function number256ToBigint(number: Number256): bigint;
@@ -20,7 +20,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
20
20
  return (mod && mod.__esModule) ? mod : { "default": mod };
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.number256ToBigint = exports.convertAlphAmount = exports.convertAmountWithDecimals = exports.prettifyNumber = exports.prettifyExactAmount = exports.prettifyTokenAmount = exports.prettifyAttoAlphAmount = exports.prettifyNumberConfig = exports.isNumeric = void 0;
23
+ exports.number256ToBigint = exports.convertAlphAmountWithDecimals = exports.convertAmountWithDecimals = exports.prettifyNumber = exports.prettifyExactAmount = exports.prettifyTokenAmount = exports.prettifyAttoAlphAmount = exports.prettifyNumberConfig = exports.isNumeric = void 0;
24
24
  // Credits:
25
25
  // 1. https://github.com/argentlabs/argent-x/blob/e63affa7f28b27333dca4081a3dcd375bb2da40b/packages/extension/src/shared/utils/number.ts
26
26
  // 2. https://github.com/ethers-io/ethers.js/blob/724881f34d428406488a1c9f9dbebe54b6edecda/src.ts/utils/fixednumber.ts
@@ -138,10 +138,11 @@ function convertAmountWithDecimals(amount, decimals) {
138
138
  }
139
139
  }
140
140
  exports.convertAmountWithDecimals = convertAmountWithDecimals;
141
- function convertAlphAmount(amount) {
141
+ // E.g. `1.23 ALPH` will be converted to `1230000000000000000`
142
+ function convertAlphAmountWithDecimals(amount) {
142
143
  return convertAmountWithDecimals(amount, 18);
143
144
  }
144
- exports.convertAlphAmount = convertAlphAmount;
145
+ exports.convertAlphAmountWithDecimals = convertAlphAmountWithDecimals;
145
146
  function number256ToBigint(number) {
146
147
  return typeof number === 'string' ? BigInt(number) : number;
147
148
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alephium/web3",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "A JS/TS library to interact with the Alephium platform",
5
5
  "license": "GPL",
6
6
  "main": "dist/src/index.js",
@@ -43,12 +43,12 @@
43
43
  "@noble/secp256k1": "1.7.1",
44
44
  "async-sema": "^3.1.1",
45
45
  "base-x": "4.0.0",
46
+ "bignumber.js": "^9.0.2",
46
47
  "blakejs": "1.2.1",
47
48
  "buffer": "^6.0.3",
48
49
  "cross-fetch": "^3.1.5",
49
50
  "elliptic": "6.5.4",
50
- "eventemitter3": "^4.0.7",
51
- "bignumber.js": "^9.0.2"
51
+ "eventemitter3": "^4.0.7"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@babel/eslint-parser": "^7.18.9",
@@ -37,9 +37,9 @@ export abstract class TransactionBuilder {
37
37
  abstract get nodeProvider(): NodeProvider
38
38
 
39
39
  static from(nodeProvider: NodeProvider): TransactionBuilder
40
- static from(baseUrl: string, apiKey?: string): TransactionBuilder
41
- static from(param0: string | NodeProvider, param1?: string): TransactionBuilder {
42
- const nodeProvider = typeof param0 === 'string' ? new NodeProvider(param0, param1) : (param0 as NodeProvider)
40
+ static from(baseUrl: string, apiKey?: string, customFetch?: typeof fetch): TransactionBuilder
41
+ static from(param0: string | NodeProvider, param1?: string, customFetch?: typeof fetch): TransactionBuilder {
42
+ const nodeProvider = typeof param0 === 'string' ? new NodeProvider(param0, param1, customFetch) : (param0 as NodeProvider)
43
43
  return new (class extends TransactionBuilder {
44
44
  get nodeProvider(): NodeProvider {
45
45
  return nodeProvider
@@ -153,7 +153,8 @@ export function convertAmountWithDecimals(amount: string | number, decimals: num
153
153
  }
154
154
  }
155
155
 
156
- export function convertAlphAmount(amount: string | number): bigint | undefined {
156
+ // E.g. `1.23 ALPH` will be converted to `1230000000000000000`
157
+ export function convertAlphAmountWithDecimals(amount: string | number): bigint | undefined {
157
158
  return convertAmountWithDecimals(amount, 18)
158
159
  }
159
160