@leofcoin/lib 1.3.7 → 1.3.8
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/exports/index.d.ts +21 -2
- package/exports/index.js +63 -10
- package/package.json +1 -1
package/exports/index.d.ts
CHANGED
|
@@ -24,9 +24,28 @@ export declare const contractFactoryMessage: string;
|
|
|
24
24
|
export declare const nativeTokenMessage: string;
|
|
25
25
|
export declare const nameServiceMessage: string;
|
|
26
26
|
export declare const validatorsMessage: string;
|
|
27
|
+
export declare const TRANSACTION_FEE_BYTES = 1024n;
|
|
28
|
+
export declare const TRANSACTION_FEE_UNIT = 10n;
|
|
29
|
+
export declare const FEE_BURN_BASIS_POINTS = 1000n;
|
|
30
|
+
export declare const FEE_BASIS_POINTS = 10000n;
|
|
31
|
+
export declare const FEE_PROTOCOL_VERSION = "1.10.9";
|
|
32
|
+
export declare const supportsTransactionFees: (version: string) => boolean;
|
|
33
|
+
export type FeePayment = {
|
|
34
|
+
to: string;
|
|
35
|
+
amount: bigint;
|
|
36
|
+
};
|
|
37
|
+
export declare const distributeTransactionFee: (fee: bigint, transactionHash: string, validatorAddresses: string[]) => {
|
|
38
|
+
burned: bigint;
|
|
39
|
+
validatorFees: Map<string, bigint>;
|
|
40
|
+
payments: FeePayment[];
|
|
41
|
+
};
|
|
42
|
+
export declare const aggregateValidatorFees: (fees: Array<{
|
|
43
|
+
fee: bigint;
|
|
44
|
+
transactionHash: string;
|
|
45
|
+
}>, validatorAddresses: string[]) => Map<string, bigint>;
|
|
27
46
|
export declare const createContractMessage: (creator: any, contract: any, constructorParameters?: never[]) => Promise<ContractMessage>;
|
|
28
|
-
export declare const calculateFee: (transaction: any, format?: boolean) => Promise<string | bigint
|
|
29
|
-
export declare const calculateTransactionFee: (transaction: any) => Promise<string | bigint
|
|
47
|
+
export declare const calculateFee: (transaction: any, format?: boolean) => Promise<string | bigint>;
|
|
48
|
+
export declare const calculateTransactionFee: (transaction: any) => Promise<string | bigint>;
|
|
30
49
|
export declare const calculateReward: (validators: any, fees: any) => [];
|
|
31
50
|
export declare const createTransactionHash: (transaction: rawTransaction | TransactionMessage | RawTransactionMessage) => Promise<Uint8Array>;
|
|
32
51
|
export declare const signTransaction: (transaction: rawTransaction, wallet: signable) => Promise<signedTransaction>;
|
package/exports/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TransactionMessage, ContractMessage, RawTransactionMessage } from '@leofcoin/messages';
|
|
2
|
-
import {
|
|
2
|
+
import { contractFactory as contractFactory$1 } from '@leofcoin/addresses';
|
|
3
3
|
export { default as nodeConfig } from './node-config.js';
|
|
4
|
-
import {
|
|
4
|
+
import { formatUnits } from '@leofcoin/utils';
|
|
5
5
|
import { toBase58 } from '@vandeurenglenn/typed-array-utils';
|
|
6
6
|
|
|
7
7
|
var contractFactory = "237,198,141,3,53,89,84,113,119,81,55,65,87,55,69,83,77,66,56,106,115,74,80,84,88,116,97,99,84,89,122,75,84,74,51,51,122,120,118,77,69,65,115,78,103,77,97,66,99,98,55,53,52,122,122,49,99,65,230,50,99,108,97,115,115,32,77,101,116,97,123,35,99,114,101,97,116,111,114,59,35,99,114,101,97,116,101,100,65,116,61,66,105,103,73,110,116,40,68,97,116,101,46,110,111,119,40,41,41,59,99,111,110,115,116,114,117,99,116,111,114,40,115,116,97,116,101,41,123,115,116,97,116,101,63,40,116,104,105,115,46,35,99,114,101,97,116,111,114,61,115,116,97,116,101,46,99,114,101,97,116,111,114,44,116,104,105,115,46,35,99,114,101,97,116,101,100,65,116,61,115,116,97,116,101,46,99,114,101,97,116,101,100,65,116,41,58,40,116,104,105,115,46,35,99,114,101,97,116,111,114,61,109,115,103,46,115,101,110,100,101,114,44,116,104,105,115,46,35,99,114,101,97,116,101,100,65,116,61,66,105,103,73,110,116,40,68,97,116,101,46,110,111,119,40,41,41,41,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,99,114,101,97,116,111,114,58,116,104,105,115,46,35,99,114,101,97,116,111,114,44,99,114,101,97,116,101,100,65,116,58,116,104,105,115,46,35,99,114,101,97,116,101,100,65,116,125,125,103,101,116,32,99,114,101,97,116,111,114,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,99,114,101,97,116,111,114,125,103,101,116,32,99,114,101,97,116,101,100,65,116,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,99,114,101,97,116,101,100,65,116,125,125,99,108,97,115,115,32,80,117,98,108,105,99,86,111,116,105,110,103,32,101,120,116,101,110,100,115,32,77,101,116,97,123,35,118,111,116,101,115,59,35,118,111,116,105,110,103,68,105,115,97,98,108,101,100,59,35,118,111,116,105,110,103,68,117,114,97,116,105,111,110,61,49,55,50,56,101,53,59,99,111,110,115,116,114,117,99,116,111,114,40,115,116,97,116,101,41,123,115,117,112,101,114,40,115,116,97,116,101,41,44,115,116,97,116,101,38,38,40,116,104,105,115,46,35,118,111,116,101,115,61,115,116,97,116,101,46,118,111,116,101,115,44,116,104,105,115,46,35,118,111,116,105,110,103,68,105,115,97,98,108,101,100,61,115,116,97,116,101,46,118,111,116,105,110,103,68,105,115,97,98,108,101,100,41,125,103,101,116,32,118,111,116,101,115,40,41,123,114,101,116,117,114,110,123,46,46,46,116,104,105,115,46,35,118,111,116,101,115,125,125,103,101,116,32,118,111,116,105,110,103,68,117,114,97,116,105,111,110,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,118,111,116,105,110,103,68,117,114,97,116,105,111,110,125,103,101,116,32,118,111,116,105,110,103,68,105,115,97,98,108,101,100,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,118,111,116,105,110,103,68,105,115,97,98,108,101,100,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,46,46,46,115,117,112,101,114,46,115,116,97,116,101,44,118,111,116,101,115,58,116,104,105,115,46,35,118,111,116,101,115,44,118,111,116,105,110,103,68,105,115,97,98,108,101,100,58,116,104,105,115,46,35,118,111,116,105,110,103,68,105,115,97,98,108,101,100,44,118,111,116,105,110,103,68,117,114,97,116,105,111,110,58,116,104,105,115,46,35,118,111,116,105,110,103,68,117,114,97,116,105,111,110,125,125,103,101,116,32,105,110,80,114,111,103,114,101,115,115,40,41,123,114,101,116,117,114,110,32,79,98,106,101,99,116,46,101,110,116,114,105,101,115,40,116,104,105,115,46,35,118,111,116,101,115,41,46,102,105,108,116,101,114,40,40,91,105,100,44,118,111,116,101,93,41,61,62,33,118,111,116,101,46,102,105,110,105,115,104,101,100,41,46,109,97,112,40,40,91,105,100,44,118,111,116,101,93,41,61,62,40,123,46,46,46,118,111,116,101,44,105,100,58,105,100,125,41,41,125,99,114,101,97,116,101,86,111,116,101,40,116,105,116,108,101,44,100,101,115,99,114,105,112,116,105,111,110,44,101,110,100,84,105,109,101,44,109,101,116,104,111,100,44,97,114,103,115,61,91,93,41,123,105,102,40,33,116,104,105,115,46,35,99,97,110,86,111,116,101,40,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,78,111,116,32,97,108,108,111,119,101,100,32,116,111,32,99,114,101,97,116,101,32,97,32,118,111,116,101,34,41,59,99,111,110,115,116,32,105,100,61,99,114,121,112,116,111,46,114,97,110,100,111,109,85,85,73,68,40,41,59,116,104,105,115,46,35,118,111,116,101,115,91,105,100,93,61,123,116,105,116,108,101,58,116,105,116,108,101,44,100,101,115,99,114,105,112,116,105,111,110,58,100,101,115,99,114,105,112,116,105,111,110,44,109,101,116,104,111,100,58,109,101,116,104,111,100,44,101,110,100,84,105,109,101,58,101,110,100,84,105,109,101,44,97,114,103,115,58,97,114,103,115,125,125,35,99,97,110,86,111,116,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,95,99,97,110,86,111,116,101,63,46,40,41,125,35,98,101,102,111,114,101,86,111,116,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,95,98,101,102,111,114,101,86,111,116,101,63,46,40,41,125,35,101,110,100,86,111,116,105,110,103,40,118,111,116,101,73,100,41,123,108,101,116,32,97,103,114,101,101,61,79,98,106,101,99,116,46,118,97,108,117,101,115,40,116,104,105,115,46,35,118,111,116,101,115,91,118,111,116,101,73,100,93,46,114,101,115,117,108,116,115,41,46,102,105,108,116,101,114,40,114,101,115,117,108,116,61,62,49,61,61,61,114,101,115,117,108,116,41,44,100,105,115,97,103,114,101,101,61,79,98,106,101,99,116,46,118,97,108,117,101,115,40,116,104,105,115,46,35,118,111,116,101,115,91,118,111,116,101,73,100,93,46,114,101,115,117,108,116,115,41,46,102,105,108,116,101,114,40,114,101,115,117,108,116,61,62,48,61,61,61,114,101,115,117,108,116,41,59,97,103,114,101,101,46,108,101,110,103,116,104,62,100,105,115,97,103,114,101,101,46,108,101,110,103,116,104,38,38,116,104,105,115,46,35,118,111,116,101,115,91,118,111,116,101,73,100,93,46,101,110,111,117,103,104,86,111,116,101,115,38,38,116,104,105,115,91,116,104,105,115,46,35,118,111,116,101,115,91,118,111,116,101,73,100,93,46,109,101,116,104,111,100,93,40,46,46,46,116,104,105,115,46,35,118,111,116,101,115,91,118,111,116,101,73,100,93,46,97,114,103,115,41,44,116,104,105,115,46,35,118,111,116,101,115,91,118,111,116,101,73,100,93,46,102,105,110,105,115,104,101,100,61,33,48,125,97,115,121,110,99,32,118,111,116,101,40,118,111,116,101,73,100,44,118,111,116,101,41,123,105,102,40,48,33,61,61,40,118,111,116,101,61,78,117,109,98,101,114,40,118,111,116,101,41,41,38,38,46,53,33,61,61,118,111,116,101,38,38,49,33,61,61,118,111,116,101,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,105,110,118,97,108,105,100,32,118,111,116,101,32,118,97,108,117,101,32,36,123,118,111,116,101,125,96,41,59,105,102,40,33,116,104,105,115,46,35,118,111,116,101,115,91,118,111,116,101,73,100,93,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,78,111,116,104,105,110,103,32,102,111,117,110,100,32,102,111,114,32,36,123,118,111,116,101,73,100,125,96,41,59,99,111,110,115,116,32,101,110,100,101,100,61,40,110,101,119,32,68,97,116,101,41,46,103,101,116,84,105,109,101,40,41,62,116,104,105,115,46,35,118,111,116,101,115,91,118,111,116,101,73,100,93,46,101,110,100,84,105,109,101,59,105,102,40,101,110,100,101,100,38,38,33,116,104,105,115,46,35,118,111,116,101,115,91,118,111,116,101,73,100,93,46,102,105,110,105,115,104,101,100,38,38,116,104,105,115,46,35,101,110,100,86,111,116,105,110,103,40,118,111,116,101,73,100,41,44,101,110,100,101,100,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,118,111,116,105,110,103,32,97,108,114,101,97,100,121,32,101,110,100,101,100,34,41,59,105,102,40,33,116,104,105,115,46,35,99,97,110,86,111,116,101,40,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,78,111,116,32,97,108,108,111,119,101,100,32,116,111,32,118,111,116,101,34,41,59,97,119,97,105,116,32,116,104,105,115,46,35,98,101,102,111,114,101,86,111,116,101,40,41,44,116,104,105,115,46,35,118,111,116,101,115,91,118,111,116,101,73,100,93,91,109,115,103,46,115,101,110,100,101,114,93,61,118,111,116,101,125,35,100,105,115,97,98,108,101,86,111,116,105,110,103,40,41,123,116,104,105,115,46,35,118,111,116,105,110,103,68,105,115,97,98,108,101,100,61,33,48,125,100,105,115,97,98,108,101,86,111,116,105,110,103,40,41,123,105,102,40,33,116,104,105,115,46,35,99,97,110,86,111,116,101,40,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,110,111,116,32,97,32,97,108,108,111,119,101,100,34,41,59,116,104,105,115,46,99,114,101,97,116,101,86,111,116,101,40,34,100,105,115,97,98,108,101,32,118,111,116,105,110,103,34,44,34,87,97,114,110,105,110,103,32,116,104,105,115,32,100,105,115,97,98,108,101,115,32,97,108,108,32,118,111,116,105,110,103,32,102,101,97,116,117,114,101,115,32,102,111,114,101,118,101,114,34,44,40,110,101,119,32,68,97,116,101,41,46,103,101,116,84,105,109,101,40,41,43,116,104,105,115,46,35,118,111,116,105,110,103,68,117,114,97,116,105,111,110,44,34,35,100,105,115,97,98,108,101,86,111,116,105,110,103,34,44,91,93,41,125,95,115,121,110,99,40,41,123,102,111,114,40,99,111,110,115,116,32,118,111,116,101,32,111,102,32,116,104,105,115,46,105,110,80,114,111,103,114,101,115,115,41,118,111,116,101,46,101,110,100,84,105,109,101,60,40,110,101,119,32,68,97,116,101,41,46,103,101,116,84,105,109,101,40,41,38,38,116,104,105,115,46,35,101,110,100,86,111,116,105,110,103,40,118,111,116,101,46,105,100,41,125,125,99,108,97,115,115,32,84,111,107,101,110,82,101,99,101,105,118,101,114,32,101,120,116,101,110,100,115,32,80,117,98,108,105,99,86,111,116,105,110,103,123,35,116,111,107,101,110,84,111,82,101,99,101,105,118,101,59,35,116,111,107,101,110,65,109,111,117,110,116,84,111,82,101,99,101,105,118,101,59,35,116,111,107,101,110,82,101,99,101,105,118,101,114,59,35,118,111,116,101,84,121,112,101,61,34,116,114,97,110,115,102,101,114,34,59,99,111,110,115,116,114,117,99,116,111,114,40,116,111,107,101,110,84,111,82,101,99,101,105,118,101,44,116,111,107,101,110,65,109,111,117,110,116,84,111,82,101,99,101,105,118,101,44,98,117,114,110,115,44,115,116,97,116,101,41,123,115,117,112,101,114,40,115,116,97,116,101,41,44,115,116,97,116,101,63,40,116,104,105,115,46,35,116,111,107,101,110,82,101,99,101,105,118,101,114,61,115,116,97,116,101,46,116,111,107,101,110,82,101,99,101,105,118,101,114,44,116,104,105,115,46,35,116,111,107,101,110,84,111,82,101,99,101,105,118,101,61,115,116,97,116,101,46,116,111,107,101,110,84,111,82,101,99,101,105,118,101,44,116,104,105,115,46,35,116,111,107,101,110,65,109,111,117,110,116,84,111,82,101,99,101,105,118,101,61,66,105,103,73,110,116,40,115,116,97,116,101,46,116,111,107,101,110,65,109,111,117,110,116,84,111,82,101,99,101,105,118,101,41,44,116,104,105,115,46,35,118,111,116,101,84,121,112,101,61,115,116,97,116,101,46,118,111,116,101,84,121,112,101,41,58,40,116,104,105,115,46,35,116,111,107,101,110,82,101,99,101,105,118,101,114,61,109,115,103,46,99,111,110,116,114,97,99,116,44,116,104,105,115,46,35,116,111,107,101,110,84,111,82,101,99,101,105,118,101,61,116,111,107,101,110,84,111,82,101,99,101,105,118,101,44,116,104,105,115,46,35,116,111,107,101,110,65,109,111,117,110,116,84,111,82,101,99,101,105,118,101,61,66,105,103,73,110,116,40,116,111,107,101,110,65,109,111,117,110,116,84,111,82,101,99,101,105,118,101,41,44,98,117,114,110,115,38,38,40,116,104,105,115,46,35,118,111,116,101,84,121,112,101,61,34,98,117,114,110,34,41,41,125,103,101,116,32,116,111,107,101,110,84,111,82,101,99,101,105,118,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,116,111,107,101,110,84,111,82,101,99,101,105,118,101,125,103,101,116,32,116,111,107,101,110,65,109,111,117,110,116,84,111,82,101,99,101,105,118,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,116,111,107,101,110,65,109,111,117,110,116,84,111,82,101,99,101,105,118,101,125,103,101,116,32,116,111,107,101,110,82,101,99,101,105,118,101,114,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,116,111,107,101,110,82,101,99,101,105,118,101,114,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,46,46,46,115,117,112,101,114,46,115,116,97,116,101,44,116,111,107,101,110,82,101,99,101,105,118,101,114,58,116,104,105,115,46,35,116,111,107,101,110,82,101,99,101,105,118,101,114,44,116,111,107,101,110,84,111,82,101,99,101,105,118,101,58,116,104,105,115,46,35,116,111,107,101,110,84,111,82,101,99,101,105,118,101,44,116,111,107,101,110,65,109,111,117,110,116,84,111,82,101,99,101,105,118,101,58,116,104,105,115,46,35,116,111,107,101,110,65,109,111,117,110,116,84,111,82,101,99,101,105,118,101,44,118,111,116,101,84,121,112,101,58,116,104,105,115,46,35,118,111,116,101,84,121,112,101,125,125,97,115,121,110,99,35,99,97,110,86,111,116,101,40,41,123,114,101,116,117,114,110,32,97,119,97,105,116,32,109,115,103,46,115,116,97,116,105,99,67,97,108,108,40,116,104,105,115,46,35,116,111,107,101,110,84,111,82,101,99,101,105,118,101,44,34,98,97,108,97,110,99,101,79,102,34,44,91,109,115,103,46,115,101,110,100,101,114,93,41,62,61,116,104,105,115,46,35,116,111,107,101,110,65,109,111,117,110,116,84,111,82,101,99,101,105,118,101,125,97,115,121,110,99,32,95,99,97,110,86,111,116,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,99,97,110,86,111,116,101,40,41,125,97,115,121,110,99,35,98,101,102,111,114,101,86,111,116,101,40,41,123,114,101,116,117,114,110,34,98,117,114,110,34,61,61,61,116,104,105,115,46,35,118,111,116,101,84,121,112,101,63,109,115,103,46,115,116,97,116,105,99,67,97,108,108,40,116,104,105,115,46,116,111,107,101,110,84,111,82,101,99,101,105,118,101,44,34,98,117,114,110,34,44,91,116,104,105,115,46,116,111,107,101,110,65,109,111,117,110,116,84,111,82,101,99,101,105,118,101,93,41,58,109,115,103,46,115,116,97,116,105,99,67,97,108,108,40,116,104,105,115,46,116,111,107,101,110,84,111,82,101,99,101,105,118,101,44,34,116,114,97,110,115,102,101,114,34,44,91,109,115,103,46,115,101,110,100,101,114,44,116,104,105,115,46,116,111,107,101,110,82,101,99,101,105,118,101,114,44,116,104,105,115,46,116,111,107,101,110,65,109,111,117,110,116,84,111,82,101,99,101,105,118,101,93,41,125,97,115,121,110,99,32,95,98,101,102,111,114,101,86,111,116,101,40,41,123,97,119,97,105,116,32,116,104,105,115,46,35,98,101,102,111,114,101,86,111,116,101,40,41,125,97,115,121,110,99,32,95,112,97,121,84,111,107,101,110,84,111,82,101,99,101,105,118,101,40,41,123,114,101,116,117,114,110,32,109,115,103,46,115,116,97,116,105,99,67,97,108,108,40,116,104,105,115,46,35,116,111,107,101,110,84,111,82,101,99,101,105,118,101,44,34,116,114,97,110,115,102,101,114,34,44,91,109,115,103,46,115,101,110,100,101,114,44,116,104,105,115,46,35,116,111,107,101,110,82,101,99,101,105,118,101,114,44,116,104,105,115,46,35,116,111,107,101,110,65,109,111,117,110,116,84,111,82,101,99,101,105,118,101,93,41,125,97,115,121,110,99,32,95,98,117,114,110,84,111,107,101,110,84,111,82,101,99,101,105,118,101,40,41,123,114,101,116,117,114,110,32,109,115,103,46,115,116,97,116,105,99,67,97,108,108,40,116,104,105,115,46,35,116,111,107,101,110,84,111,82,101,99,101,105,118,101,44,34,98,117,114,110,34,44,91,116,104,105,115,46,35,116,111,107,101,110,65,109,111,117,110,116,84,111,82,101,99,101,105,118,101,93,41,125,35,99,104,97,110,103,101,84,111,107,101,110,84,111,82,101,99,101,105,118,101,40,97,100,100,114,101,115,115,41,123,116,104,105,115,46,35,116,111,107,101,110,84,111,82,101,99,101,105,118,101,61,97,100,100,114,101,115,115,125,35,99,104,97,110,103,101,84,111,107,101,110,65,109,111,117,110,116,84,111,82,101,99,101,105,118,101,40,97,109,111,117,110,116,41,123,116,104,105,115,46,35,116,111,107,101,110,65,109,111,117,110,116,84,111,82,101,99,101,105,118,101,61,97,109,111,117,110,116,125,35,99,104,97,110,103,101,86,111,116,101,84,121,112,101,40,116,121,112,101,41,123,116,104,105,115,46,35,118,111,116,101,84,121,112,101,61,116,121,112,101,125,35,103,101,116,84,111,107,101,110,115,79,117,116,40,97,109,111,117,110,116,44,114,101,99,101,105,118,101,114,41,123,114,101,116,117,114,110,32,109,115,103,46,99,97,108,108,40,116,104,105,115,46,35,116,111,107,101,110,82,101,99,101,105,118,101,114,44,34,116,114,97,110,115,102,101,114,34,44,91,116,104,105,115,46,35,116,111,107,101,110,82,101,99,101,105,118,101,114,44,114,101,99,101,105,118,101,114,44,97,109,111,117,110,116,93,41,125,97,115,121,110,99,32,99,104,97,110,103,101,86,111,116,101,84,121,112,101,40,116,121,112,101,41,123,105,102,40,33,116,104,105,115,46,35,99,97,110,86,111,116,101,40,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,110,111,116,32,97,32,97,108,108,111,119,101,100,34,41,59,105,102,40,34,116,114,97,110,115,102,101,114,34,61,61,61,116,104,105,115,46,35,118,111,116,101,84,121,112,101,38,38,97,119,97,105,116,32,116,104,105,115,46,35,98,97,108,97,110,99,101,40,41,62,48,110,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,103,101,116,32,116,111,107,101,110,115,32,111,117,116,32,102,105,114,115,116,32,111,114,32,116,104,101,121,32,98,101,32,108,111,115,116,32,102,111,114,101,118,101,114,34,41,59,116,104,105,115,46,99,114,101,97,116,101,86,111,116,101,40,34,99,104,97,110,103,101,32,116,104,101,32,116,111,107,101,110,32,97,109,111,117,110,116,32,116,111,32,114,101,99,101,105,118,101,34,44,34,115,101,116,32,116,111,107,101,110,65,109,111,117,110,116,84,111,82,101,99,101,105,118,101,34,44,40,110,101,119,32,68,97,116,101,41,46,103,101,116,84,105,109,101,40,41,43,116,104,105,115,46,118,111,116,105,110,103,68,117,114,97,116,105,111,110,44,34,35,99,104,97,110,103,101,86,111,116,101,84,121,112,101,34,44,91,116,121,112,101,93,41,125,103,101,116,84,111,107,101,110,115,79,117,116,40,97,109,111,117,110,116,44,114,101,99,101,105,118,101,114,41,123,105,102,40,33,116,104,105,115,46,35,99,97,110,86,111,116,101,40,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,110,111,116,32,97,32,97,108,108,111,119,101,100,34,41,59,116,104,105,115,46,99,114,101,97,116,101,86,111,116,101,40,34,119,105,116,104,100,114,97,119,32,97,108,108,32,116,111,107,101,110,115,34,44,96,119,105,116,104,100,114,97,119,32,97,108,108,32,116,111,107,101,110,115,32,116,111,32,36,123,114,101,99,101,105,118,101,114,125,96,44,40,110,101,119,32,68,97,116,101,41,46,103,101,116,84,105,109,101,40,41,43,116,104,105,115,46,118,111,116,105,110,103,68,117,114,97,116,105,111,110,44,34,35,103,101,116,84,111,107,101,110,115,79,117,116,34,44,91,97,109,111,117,110,116,44,114,101,99,101,105,118,101,114,93,41,125,99,104,97,110,103,101,84,111,107,101,110,65,109,111,117,110,116,84,111,82,101,99,101,105,118,101,40,41,123,105,102,40,33,116,104,105,115,46,35,99,97,110,86,111,116,101,40,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,110,111,116,32,97,32,97,108,108,111,119,101,100,34,41,59,116,104,105,115,46,99,114,101,97,116,101,86,111,116,101,40,34,99,104,97,110,103,101,32,116,104,101,32,116,111,107,101,110,32,97,109,111,117,110,116,32,116,111,32,114,101,99,101,105,118,101,34,44,34,115,101,116,32,116,111,107,101,110,65,109,111,117,110,116,84,111,82,101,99,101,105,118,101,34,44,40,110,101,119,32,68,97,116,101,41,46,103,101,116,84,105,109,101,40,41,43,116,104,105,115,46,118,111,116,105,110,103,68,117,114,97,116,105,111,110,44,34,35,99,104,97,110,103,101,84,111,107,101,110,65,109,111,117,110,116,84,111,82,101,99,101,105,118,101,34,44,91,93,41,125,35,98,97,108,97,110,99,101,40,41,123,114,101,116,117,114,110,32,109,115,103,46,115,116,97,116,105,99,67,97,108,108,40,116,104,105,115,46,35,116,111,107,101,110,84,111,82,101,99,101,105,118,101,44,34,98,97,108,97,110,99,101,79,102,34,44,91,116,104,105,115,46,35,116,111,107,101,110,82,101,99,101,105,118,101,114,93,41,125,97,115,121,110,99,32,99,104,97,110,103,101,84,111,107,101,110,84,111,82,101,99,101,105,118,101,40,41,123,105,102,40,33,116,104,105,115,46,35,99,97,110,86,111,116,101,40,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,110,111,116,32,97,32,97,108,108,111,119,101,100,34,41,59,105,102,40,48,110,33,61,61,97,119,97,105,116,32,116,104,105,115,46,35,98,97,108,97,110,99,101,40,41,38,38,34,116,114,97,110,115,102,101,114,34,61,61,61,116,104,105,115,46,35,118,111,116,101,84,121,112,101,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,103,101,116,32,116,111,107,101,110,115,32,111,117,116,32,102,105,114,115,116,32,111,114,32,116,104,101,121,32,98,101,32,108,111,115,116,32,102,111,114,101,118,101,114,34,41,59,116,104,105,115,46,99,114,101,97,116,101,86,111,116,101,40,34,99,104,97,110,103,101,32,116,104,101,32,116,111,107,101,110,32,116,111,32,114,101,99,101,105,118,101,34,44,34,115,101,116,32,116,111,107,101,110,84,111,82,101,99,101,105,118,101,32,116,111,32,97,32,110,101,119,32,97,100,100,114,101,115,115,34,44,40,110,101,119,32,68,97,116,101,41,46,103,101,116,84,105,109,101,40,41,43,116,104,105,115,46,118,111,116,105,110,103,68,117,114,97,116,105,111,110,44,34,35,99,104,97,110,103,101,84,111,107,101,110,84,111,82,101,99,101,105,118,101,34,44,91,93,41,125,125,99,108,97,115,115,32,70,97,99,116,111,114,121,32,101,120,116,101,110,100,115,32,84,111,107,101,110,82,101,99,101,105,118,101,114,123,35,110,97,109,101,61,34,76,101,111,102,99,111,105,110,67,111,110,116,114,97,99,116,70,97,99,116,111,114,121,34,59,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,61,66,105,103,73,110,116,40,48,41,59,35,99,111,110,116,114,97,99,116,115,61,91,93,59,99,111,110,115,116,114,117,99,116,111,114,40,116,111,107,101,110,84,111,82,101,99,101,105,118,101,44,116,111,107,101,110,65,109,111,117,110,116,84,111,82,101,99,101,105,118,101,44,115,116,97,116,101,41,123,115,117,112,101,114,40,116,111,107,101,110,84,111,82,101,99,101,105,118,101,44,116,111,107,101,110,65,109,111,117,110,116,84,111,82,101,99,101,105,118,101,44,33,48,44,115,116,97,116,101,41,44,115,116,97,116,101,38,38,40,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,61,115,116,97,116,101,46,99,111,110,116,114,97,99,116,115,44,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,61,115,116,97,116,101,46,116,111,116,97,108,67,111,110,116,114,97,99,116,115,41,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,46,46,46,115,117,112,101,114,46,115,116,97,116,101,44,116,111,116,97,108,67,111,110,116,114,97,99,116,115,58,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,44,99,111,110,116,114,97,99,116,115,58,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,125,125,103,101,116,32,110,97,109,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,110,97,109,101,125,103,101,116,32,99,111,110,116,114,97,99,116,115,40,41,123,114,101,116,117,114,110,91,46,46,46,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,93,125,103,101,116,32,116,111,116,97,108,67,111,110,116,114,97,99,116,115,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,125,105,115,82,101,103,105,115,116,101,114,101,100,40,97,100,100,114,101,115,115,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,46,105,110,99,108,117,100,101,115,40,97,100,100,114,101,115,115,41,125,35,105,115,67,114,101,97,116,111,114,40,97,100,100,114,101,115,115,41,123,114,101,116,117,114,110,32,109,115,103,46,115,116,97,116,105,99,67,97,108,108,40,97,100,100,114,101,115,115,44,34,99,114,101,97,116,111,114,34,44,91,109,115,103,46,115,101,110,100,101,114,93,41,125,105,115,67,114,101,97,116,111,114,40,97,100,100,114,101,115,115,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,105,115,67,114,101,97,116,111,114,40,97,100,100,114,101,115,115,41,125,97,115,121,110,99,32,114,101,103,105,115,116,101,114,67,111,110,116,114,97,99,116,40,97,100,100,114,101,115,115,41,123,105,102,40,33,97,119,97,105,116,32,116,104,105,115,46,105,115,67,114,101,97,116,111,114,40,97,100,100,114,101,115,115,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,89,111,117,32,100,111,110,39,116,32,111,119,110,32,116,104,97,116,32,99,111,110,116,114,97,99,116,34,41,59,105,102,40,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,46,105,110,99,108,117,100,101,115,40,97,100,100,114,101,115,115,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,97,108,114,101,97,100,121,32,114,101,103,105,115,116,101,114,101,100,34,41,59,97,119,97,105,116,32,116,104,105,115,46,95,112,97,121,84,111,107,101,110,84,111,82,101,99,101,105,118,101,40,41,44,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,43,61,49,110,44,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,46,112,117,115,104,40,97,100,100,114,101,115,115,41,125,125,114,101,116,117,114,110,32,70,97,99,116,111,114,121,59,88,91,34,73,72,78,89,50,71,81,71,71,75,83,50,86,68,72,86,80,72,84,53,86,66,55,83,71,68,76,77,80,82,67,90,51,89,54,69,71,66,52,50,66,76,84,55,51,87,53,72,67,78,84,65,72,51,87,78,88,66,89,34,44,34,49,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,48,34,93";
|
|
@@ -19,6 +19,63 @@ const contractFactoryMessage = bytecodes.contractFactory;
|
|
|
19
19
|
const nativeTokenMessage = bytecodes.nativeToken;
|
|
20
20
|
const nameServiceMessage = bytecodes.nameService;
|
|
21
21
|
const validatorsMessage = bytecodes.validators;
|
|
22
|
+
const TRANSACTION_FEE_BYTES = 1024n;
|
|
23
|
+
const TRANSACTION_FEE_UNIT = 10n;
|
|
24
|
+
const FEE_BURN_BASIS_POINTS = 1000n;
|
|
25
|
+
const FEE_BASIS_POINTS = 10000n;
|
|
26
|
+
const FEE_PROTOCOL_VERSION = '1.10.9';
|
|
27
|
+
const parseProtocolVersion = (version) => {
|
|
28
|
+
const match = /^(\d+)\.(\d+)\.(\d+)/.exec(version);
|
|
29
|
+
return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : undefined;
|
|
30
|
+
};
|
|
31
|
+
const supportsTransactionFees = (version) => {
|
|
32
|
+
const actual = parseProtocolVersion(version);
|
|
33
|
+
const required = parseProtocolVersion(FEE_PROTOCOL_VERSION);
|
|
34
|
+
if (!actual)
|
|
35
|
+
return false;
|
|
36
|
+
for (let index = 0; index < required.length; index += 1) {
|
|
37
|
+
if (actual[index] !== required[index])
|
|
38
|
+
return actual[index] > required[index];
|
|
39
|
+
}
|
|
40
|
+
return true;
|
|
41
|
+
};
|
|
42
|
+
const feeRotationIndex = (transactionHash, validatorCount) => {
|
|
43
|
+
let value = 0n;
|
|
44
|
+
for (const character of transactionHash)
|
|
45
|
+
value = (value * 31n + BigInt(character.charCodeAt(0))) % 4294967291n;
|
|
46
|
+
return Number(value % BigInt(validatorCount));
|
|
47
|
+
};
|
|
48
|
+
const distributeTransactionFee = (fee, transactionHash, validatorAddresses) => {
|
|
49
|
+
const canonicalValidators = [...new Set(validatorAddresses)].sort();
|
|
50
|
+
if (canonicalValidators.length === 0)
|
|
51
|
+
throw new Error('cannot distribute transaction fee without validators');
|
|
52
|
+
if (fee < 0n)
|
|
53
|
+
throw new Error('transaction fee cannot be negative');
|
|
54
|
+
const burned = (fee * FEE_BURN_BASIS_POINTS) / FEE_BASIS_POINTS;
|
|
55
|
+
const validatorPool = fee - burned;
|
|
56
|
+
const count = BigInt(canonicalValidators.length);
|
|
57
|
+
const base = validatorPool / count;
|
|
58
|
+
const remainder = Number(validatorPool % count);
|
|
59
|
+
const start = feeRotationIndex(transactionHash, canonicalValidators.length);
|
|
60
|
+
const validatorFees = new Map(canonicalValidators.map((validator) => [validator, base]));
|
|
61
|
+
for (let index = 0; index < remainder; index += 1) {
|
|
62
|
+
const validator = canonicalValidators[(start + index) % canonicalValidators.length];
|
|
63
|
+
validatorFees.set(validator, validatorFees.get(validator) + 1n);
|
|
64
|
+
}
|
|
65
|
+
const payments = [...validatorFees.entries()]
|
|
66
|
+
.filter(([, amount]) => amount > 0n)
|
|
67
|
+
.map(([to, amount]) => ({ to, amount }));
|
|
68
|
+
return { burned, validatorFees, payments };
|
|
69
|
+
};
|
|
70
|
+
const aggregateValidatorFees = (fees, validatorAddresses) => {
|
|
71
|
+
const totals = new Map([...new Set(validatorAddresses)].sort().map((validator) => [validator, 0n]));
|
|
72
|
+
for (const entry of fees) {
|
|
73
|
+
const { validatorFees } = distributeTransactionFee(entry.fee, entry.transactionHash, validatorAddresses);
|
|
74
|
+
for (const [validator, amount] of validatorFees)
|
|
75
|
+
totals.set(validator, totals.get(validator) + amount);
|
|
76
|
+
}
|
|
77
|
+
return totals;
|
|
78
|
+
};
|
|
22
79
|
const createContractMessage = async (creator, contract, constructorParameters = []) => {
|
|
23
80
|
return new ContractMessage({
|
|
24
81
|
creator,
|
|
@@ -27,14 +84,10 @@ const createContractMessage = async (creator, contract, constructorParameters =
|
|
|
27
84
|
});
|
|
28
85
|
};
|
|
29
86
|
const calculateFee = async (transaction, format = false) => {
|
|
30
|
-
// excluded from fees
|
|
31
|
-
if (transaction.to === validators$1)
|
|
32
|
-
return 0;
|
|
33
87
|
transaction = await new TransactionMessage(transaction);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
fee
|
|
37
|
-
// fee = fee.div(1000000)
|
|
88
|
+
const encodedBytes = BigInt(transaction.encoded.length);
|
|
89
|
+
const units = (encodedBytes + TRANSACTION_FEE_BYTES - 1n) / TRANSACTION_FEE_BYTES;
|
|
90
|
+
const fee = units * TRANSACTION_FEE_UNIT;
|
|
38
91
|
return format ? formatUnits(fee.toString()) : fee;
|
|
39
92
|
};
|
|
40
93
|
const calculateTransactionFee = (transaction) => {
|
|
@@ -91,4 +144,4 @@ const prepareContractTransactionAndSign = async (owner, contract, constructorPar
|
|
|
91
144
|
return signTransaction(transaction, wallet);
|
|
92
145
|
};
|
|
93
146
|
|
|
94
|
-
export { calculateFee, calculateReward, calculateTransactionFee, contractFactoryMessage, createContractMessage, createTransactionHash, nameServiceMessage, nativeTokenMessage, prepareContractTransaction, prepareContractTransactionAndSign, signTransaction, validatorsMessage };
|
|
147
|
+
export { FEE_BASIS_POINTS, FEE_BURN_BASIS_POINTS, FEE_PROTOCOL_VERSION, TRANSACTION_FEE_BYTES, TRANSACTION_FEE_UNIT, aggregateValidatorFees, calculateFee, calculateReward, calculateTransactionFee, contractFactoryMessage, createContractMessage, createTransactionHash, distributeTransactionFee, nameServiceMessage, nativeTokenMessage, prepareContractTransaction, prepareContractTransactionAndSign, signTransaction, supportsTransactionFees, validatorsMessage };
|