@tatumio/flow 2.0.1-alpha.351 → 2.0.1-alpha.353

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. package/package.json +10 -8
  2. package/src/index.d.ts +1 -0
  3. package/src/index.js +1 -0
  4. package/src/index.js.map +1 -1
  5. package/src/lib/flow.constants.d.ts +12 -0
  6. package/src/lib/flow.constants.js +13 -1
  7. package/src/lib/flow.constants.js.map +1 -1
  8. package/src/lib/flow.sdk.d.ts +64 -51
  9. package/src/lib/flow.sdk.errors.d.ts +4 -2
  10. package/src/lib/flow.sdk.errors.js +8 -5
  11. package/src/lib/flow.sdk.errors.js.map +1 -1
  12. package/src/lib/flow.sdk.js +12 -1
  13. package/src/lib/flow.sdk.js.map +1 -1
  14. package/src/lib/flow.types.d.ts +56 -0
  15. package/src/lib/flow.types.js +38 -0
  16. package/src/lib/flow.types.js.map +1 -0
  17. package/src/lib/services/flow.blockchain.js +7 -7
  18. package/src/lib/services/flow.blockchain.js.map +1 -1
  19. package/src/lib/services/flow.kms.d.ts +11 -9
  20. package/src/lib/services/flow.kms.js +22 -10
  21. package/src/lib/services/flow.kms.js.map +1 -1
  22. package/src/lib/services/flow.provider.d.ts +11 -0
  23. package/src/lib/services/flow.provider.js +17 -0
  24. package/src/lib/services/flow.provider.js.map +1 -0
  25. package/src/lib/services/flow.tx.d.ts +86 -94
  26. package/src/lib/services/flow.tx.js +389 -307
  27. package/src/lib/services/flow.tx.js.map +1 -1
  28. package/src/lib/services/flow.tx.templates.d.ts +1 -0
  29. package/src/lib/services/flow.tx.templates.js +23 -12
  30. package/src/lib/services/flow.tx.templates.js.map +1 -1
  31. package/src/lib/services/flow.virtualAccount.d.ts +31 -0
  32. package/src/lib/services/flow.virtualAccount.js +20 -0
  33. package/src/lib/services/flow.virtualAccount.js.map +1 -0
  34. package/src/lib/utils/flow.utils.d.ts +6 -0
  35. package/src/lib/utils/flow.utils.js +18 -0
  36. package/src/lib/utils/flow.utils.js.map +1 -0
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.flowProvider = void 0;
4
+ const api_client_1 = require("@tatumio/api-client");
5
+ const flowProvider = (args) => {
6
+ return {
7
+ getProvider() {
8
+ return (args.provider ||
9
+ `${process.env['TATUM_API_URL'] || api_client_1.TATUM_API_CONSTANTS.URL}/v3/blockchain/node/FLOW/${api_client_1.TATUM_API_CONSTANTS.API_KEY}`);
10
+ },
11
+ isTestnet() {
12
+ return args.testnet;
13
+ },
14
+ };
15
+ };
16
+ exports.flowProvider = flowProvider;
17
+ //# sourceMappingURL=flow.provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flow.provider.js","sourceRoot":"","sources":["../../../../../../../packages/blockchain/flow/src/lib/services/flow.provider.ts"],"names":[],"mappings":";;;AAAA,oDAAyD;AAOlD,MAAM,YAAY,GAAG,CAAC,IAA6C,EAAE,EAAE;IAC5E,OAAO;QACL,WAAW;YACT,OAAO,CACL,IAAI,CAAC,QAAQ;gBACb,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,gCAAmB,CAAC,GAAG,4BACxD,gCAAmB,CAAC,OACtB,EAAE,CACH,CAAA;QACH,CAAC;QACD,SAAS;YACP,OAAO,IAAI,CAAC,OAAO,CAAA;QACrB,CAAC;KACF,CAAA;AACH,CAAC,CAAA;AAdY,QAAA,YAAY,gBAcxB"}
@@ -1,127 +1,119 @@
1
- import { ChainFlowBurnNft, ChainFlowMintMultipleNft, ChainFlowMintNft, ChainFlowTransferNft, TransferFlow, TransferFlowCustomTx } from '@tatumio/shared-core';
2
- import { SDKArguments } from '@tatumio/shared-abstract-sdk';
3
- export declare const FLOW_TESTNET_ADDRESSES: {
4
- FlowToken: string;
5
- FungibleToken: string;
6
- FUSD: string;
7
- TatumMultiNFT: string;
8
- };
9
- export declare const FLOW_MAINNET_ADDRESSES: {
10
- FlowToken: string;
11
- FungibleToken: string;
12
- FUSD: string;
13
- TatumMultiNFT: string;
14
- };
15
- export declare const flowTxService: (args: SDKArguments) => {
1
+ import { Account, AccountAuthorization, AccountSigner, FixedFlowCustomTransactionPK, FlowPrivateKeyOrSignatureId } from '../flow.types';
2
+ import { BurnNftFlowPK, FlowCreateAddressFromPubKeySecret, FlowTransactionPK, MintMultipleNftFlowPK, MintNftFlowPK, TransferNftFlowPK } from '@tatumio/api-client';
3
+ import { FlowProvider } from './flow.provider';
4
+ export declare type MintFlowNft = FlowPrivateKeyOrSignatureId<MintNftFlowPK>;
5
+ export declare type MintMultipleFlowNft = FlowPrivateKeyOrSignatureId<MintMultipleNftFlowPK>;
6
+ export declare type TransferFlowNft = FlowPrivateKeyOrSignatureId<TransferNftFlowPK>;
7
+ export declare type BurnFlowNft = FlowPrivateKeyOrSignatureId<BurnNftFlowPK>;
8
+ export declare type TransferFlowCustomTx = FlowPrivateKeyOrSignatureId<FixedFlowCustomTransactionPK>;
9
+ export declare type TransferFlow = FlowPrivateKeyOrSignatureId<FlowTransactionPK>;
10
+ export declare type CreateAddressFromPubKey = FlowPrivateKeyOrSignatureId<FlowCreateAddressFromPubKeySecret>;
11
+ export declare const flowTxService: (provider: FlowProvider, apiCalls: {
12
+ getSignKey: (isPayer: boolean) => Promise<{
13
+ keyId: number;
14
+ address: string;
15
+ }>;
16
+ signWithKey: (data: string, isPayer: boolean) => Promise<{
17
+ signature: string;
18
+ }>;
19
+ broadcast: (txData: string, signatureId?: string, proposalKey?: number) => Promise<{
20
+ txId: string;
21
+ failed?: boolean;
22
+ }>;
23
+ }) => {
16
24
  sign: (pk: string, msg: Buffer) => string;
17
25
  getSigner: (pk: string, address: string, keyId?: number) => {
18
- signer: (account: any) => any;
26
+ signer: (account: Account) => Promise<AccountAuthorization>;
19
27
  };
20
28
  getApiSigner: (isPayer: boolean) => {
21
- signer: (account: any) => Promise<any>;
29
+ signer: (account: Account) => Promise<AccountAuthorization>;
22
30
  keyHash: string;
23
31
  };
24
32
  /**
25
33
  * Create account on the FLOW network. It automatically creates 100 0-weight proposal keys, which are managed by Tatum API - index 1-100.
26
34
  * Main 1000 weight authorizer key is stored as a first one on index 0.
27
- * @param testnet if we use testnet or not
28
- * @param publicKey public key to assign to address as authorizer (1000 weight) key
29
- * @param signerAddress address of the authorizer creator of the address on the chain
30
- * @param signerPrivateKey private key of the authorizer creator of the address on the chain
31
- * @param proposer function to obtain proposer key from
32
- * @param payer function to obtain payer key from
33
- */
34
- createAccountFromPublicKey: (testnet: boolean, publicKey: string, signerAddress: string, signerPrivateKey: string, proposer?: (isPayer: boolean) => any, payer?: (isPayer: boolean) => any) => Promise<{
35
- txId: string;
36
- address: string;
37
- }>;
38
- /**
39
- * Add public key to existing blockchain address with defined weight
40
- * @param testnet
41
- * @param publicKey key to add
42
- * @param signerAddress address of the authorizer key
43
- * @param signerPrivateKey key of the authorize key
44
- * @param weight defaults to 1000 - weight of the key
45
- * @param proposer function to obtain proposer key from
46
- * @param payer function to obtain payer key from
47
- */
48
- addPublicKeyToAccount: (testnet: boolean, publicKey: string, signerAddress: string, signerPrivateKey: string, weight?: number, proposer?: (args: any) => any, payer?: (args: any) => any) => Promise<{
49
- txId: string;
50
- address: string;
51
- }>;
52
- getNftMetadata: (testnet: boolean, account: string, id: string, contractAddress: string) => Promise<any>;
53
- getNftTokenByAddress: (testnet: boolean, account: string, tokenType: string) => Promise<any>;
54
- /**
55
- * Send Flow NFT mint token transaction to the blockchain. This method broadcasts signed transaction to the blockchain.
56
- * This operation is irreversible.
57
- * @param testnet
58
35
  * @param body content of the transaction to broadcast
59
36
  * @param proposer function to obtain proposer key from
60
37
  * @param payer function to obtain payer key from
61
- * @returns txId id of the transaction in the blockchain
62
38
  */
63
- sendNftMintToken: (testnet: boolean, body: ChainFlowMintNft, proposer?: (isPayer: boolean) => any, payer?: (isPayer: boolean) => any) => Promise<{
64
- txId: string;
65
- tokenId: string;
39
+ createAccountFromPublicKey: (body: CreateAddressFromPubKey, proposer?: ((isPayer: boolean) => AccountSigner) | undefined, payer?: ((isPayer: boolean) => AccountSigner) | undefined) => Promise<import("@tatumio/api-client").SignatureId | {
40
+ txId?: string | undefined;
41
+ address?: string | undefined;
66
42
  }>;
67
43
  /**
68
- * Send Flow NFT mint multiple tokens transaction to the blockchain. This method broadcasts signed transaction to the blockchain.
69
- * This operation is irreversible.
70
- * @param testnet
71
- * @param body content of the transaction to broadcast
72
- * @param proposer function to obtain proposer key from
73
- * @param payer function to obtain payer key from
74
- * @returns txId id of the transaction in the blockchain
75
- */
76
- sendNftMintMultipleToken: (testnet: boolean, body: ChainFlowMintMultipleNft, proposer?: (isPayer: boolean) => any, payer?: (isPayer: boolean) => any) => Promise<{
77
- txId: string;
78
- tokenId: number[];
79
- }>;
80
- /**
81
- * Send Flow NFT transfer token transaction to the blockchain. This method broadcasts signed transaction to the blockchain.
82
- * This operation is irreversible.
83
- * @param testnet
44
+ * Add public key to existing blockchain address with defined weight
84
45
  * @param body content of the transaction to broadcast
85
46
  * @param proposer function to obtain proposer key from
86
47
  * @param payer function to obtain payer key from
87
- * @returns {txId: string, events: any[]} id of the transaction in the blockchain and events this tx produced
88
48
  */
89
- sendNftTransferToken: (testnet: boolean, body: ChainFlowTransferNft, proposer?: (isPayer: boolean) => any, payer?: (isPayer: boolean) => any) => Promise<{
90
- txId: string;
91
- }>;
49
+ addPublicKeyToAccount: (body: CreateAddressFromPubKey, proposer?: ((isPayer: boolean) => AccountSigner) | undefined, payer?: ((isPayer: boolean) => AccountSigner) | undefined) => Promise<import("@tatumio/api-client").TransactionHash | import("@tatumio/api-client").SignatureId>;
50
+ nft: {
51
+ getNftMetadata: (account: string, id: string, contractAddress: string) => Promise<any>;
52
+ getNftTokenByAddress: (account: string, tokenType: string) => Promise<any>;
53
+ /**
54
+ * Send Flow NFT mint token transaction to the blockchain. This method broadcasts signed transaction to the blockchain.
55
+ * This operation is irreversible.
56
+ * @param body content of the transaction to broadcast
57
+ * @param proposer function to obtain proposer key from
58
+ * @param payer function to obtain payer key from
59
+ * @returns txId id of the transaction in the blockchain
60
+ */
61
+ sendNftMintToken: (body: MintFlowNft, proposer?: ((isPayer: boolean) => AccountSigner) | undefined, payer?: ((isPayer: boolean) => AccountSigner) | undefined) => Promise<import("@tatumio/api-client").TransactionHash | import("@tatumio/api-client").SignatureId | import("@tatumio/api-client").FlowMintedResult | import("@tatumio/api-client").SolanaMintedResult | import("@tatumio/api-client").AlgorandMintedResult>;
62
+ /**
63
+ * Send Flow NFT mint multiple tokens transaction to the blockchain. This method broadcasts signed transaction to the blockchain.
64
+ * This operation is irreversible.
65
+ * @param body content of the transaction to broadcast
66
+ * @param proposer function to obtain proposer key from
67
+ * @param payer function to obtain payer key from
68
+ * @returns txId id of the transaction in the blockchain
69
+ */
70
+ sendNftMintMultipleToken: (body: MintMultipleFlowNft, proposer?: ((isPayer: boolean) => AccountSigner) | undefined, payer?: ((isPayer: boolean) => AccountSigner) | undefined) => Promise<import("@tatumio/api-client").TransactionHash | import("@tatumio/api-client").SignatureId | import("@tatumio/api-client").FlowMintedMultipleResult>;
71
+ /**
72
+ * Send Flow NFT transfer token transaction to the blockchain. This method broadcasts signed transaction to the blockchain.
73
+ * This operation is irreversible.
74
+ * @param body content of the transaction to broadcast
75
+ * @param proposer function to obtain proposer key from
76
+ * @param payer function to obtain payer key from
77
+ * @returns {txId: string, events: any[]} id of the transaction in the blockchain and events this tx produced
78
+ */
79
+ sendNftTransferToken: (body: TransferFlowNft, proposer?: ((isPayer: boolean) => AccountSigner) | undefined, payer?: ((isPayer: boolean) => AccountSigner) | undefined) => Promise<import("@tatumio/api-client").TransactionHash | import("@tatumio/api-client").SignatureId>;
80
+ /**
81
+ * Send Flow NFT burn token transaction to the blockchain. This method broadcasts signed transaction to the blockchain.
82
+ * This operation is irreversible.
83
+ * @param body content of the transaction to broadcast
84
+ * @param proposer function to obtain proposer key from
85
+ * @param payer function to obtain payer key from
86
+ * @returns txId id of the transaction in the blockchain
87
+ */
88
+ sendNftBurnToken: (body: BurnFlowNft, proposer?: ((isPayer: boolean) => AccountSigner) | undefined, payer?: ((isPayer: boolean) => AccountSigner) | undefined) => Promise<import("@tatumio/api-client").TransactionHash | import("@tatumio/api-client").SignatureId>;
89
+ };
92
90
  /**
93
- * Send Flow NFT burn token transaction to the blockchain. This method broadcasts signed transaction to the blockchain.
94
- * This operation is irreversible.
95
- * @param testnet
91
+ * Send FLOW or FUSD from account to account.
96
92
  * @param body content of the transaction to broadcast
97
93
  * @param proposer function to obtain proposer key from
98
94
  * @param payer function to obtain payer key from
99
95
  * @returns txId id of the transaction in the blockchain
100
96
  */
101
- sendNftBurnToken: (testnet: boolean, body: ChainFlowBurnNft, proposer?: (isPayer: boolean) => any, payer?: (isPayer: boolean) => any) => Promise<{
102
- txId: string;
103
- }>;
97
+ sendTransaction: (body: TransferFlow, proposer?: ((isPayer: boolean) => AccountSigner) | undefined, payer?: ((isPayer: boolean) => AccountSigner) | undefined) => Promise<import("@tatumio/api-client").TransactionHash | import("@tatumio/api-client").SignatureId>;
104
98
  /**
105
99
  * Send custom transaction to the FLOW network
106
- * @param testnet
107
100
  * @param body content of the transaction to broadcast
108
101
  * @param proposer function to obtain proposer key from
109
102
  * @param payer function to obtain payer key from
110
103
  * @returns txId id of the transaction in the blockchain
111
104
  */
112
- sendCustomTransaction: (testnet: boolean, body: TransferFlowCustomTx, proposer?: (isPayer: boolean) => any, payer?: (isPayer: boolean) => any) => Promise<{
113
- txId: string;
114
- events: any[];
115
- }>;
116
- /**
117
- * Send FLOW or FUSD from account to account.
118
- * @param testnet
119
- * @param body content of the transaction to broadcast
120
- * @param proposer function to obtain proposer key from
121
- * @param payer function to obtain payer key from
122
- * @returns txId id of the transaction in the blockchain
123
- */
124
- sendTransaction: (testnet: boolean, body: TransferFlow, proposer?: (isPayer: boolean) => any, payer?: (isPayer: boolean) => any) => Promise<{
125
- txId: string;
126
- }>;
105
+ sendCustomTransaction: (body: TransferFlowCustomTx, proposer?: ((isPayer: boolean) => AccountSigner) | undefined, payer?: ((isPayer: boolean) => AccountSigner) | undefined) => Promise<import("@tatumio/api-client").TransactionHash | import("@tatumio/api-client").SignatureId>;
106
+ templates: {
107
+ deployNftTokenTypeWithMinterTxTemplate: (testnet: boolean) => string;
108
+ metadataNftTokenScript: (testnet: boolean) => string;
109
+ tokenByAddressNftTokenScript: (testnet: boolean) => string;
110
+ mintNftTokenTxTemplate: (testnet: boolean) => string;
111
+ mintMultipleNftTokenTxTemplate: (testnet: boolean) => string;
112
+ burnNftTokenTxTemplate: (testnet: boolean) => string;
113
+ transferNftTokenTxTemplate: (testnet: boolean) => string;
114
+ prepareAddPublicKeyToAccountTxTemplate: () => string;
115
+ prepareTransferTxTemplate: (testnet: boolean, tokenAddress: string, tokenName: string, tokenStorage: string) => string;
116
+ prepareBalanceTxTemplate: (testnet: boolean, tokenAddress: string, tokenName: string, tokenStorage: string) => string;
117
+ prepareCreateAccountWithFUSDFromPublicKeyTxTemplate: (testnet: boolean) => string;
118
+ };
127
119
  };