@airgap/base 0.13.45-beta.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.
- package/LICENSE.md +7 -0
- package/index.d.ts +1 -0
- package/index.js +18 -0
- package/index.js.map +1 -0
- package/package.json +63 -0
- package/readme.md +121 -0
- package/v1/client/info/BaseInfoClient.d.ts +2 -0
- package/v1/client/info/BaseInfoClient.js +3 -0
- package/v1/client/info/BaseInfoClient.js.map +1 -0
- package/v1/client/node/BaseNodeClient.d.ts +5 -0
- package/v1/client/node/BaseNodeClient.js +3 -0
- package/v1/client/node/BaseNodeClient.js.map +1 -0
- package/v1/client/node/HttpBaseNodeClient.d.ts +7 -0
- package/v1/client/node/HttpBaseNodeClient.js +114 -0
- package/v1/client/node/HttpBaseNodeClient.js.map +1 -0
- package/v1/index.d.ts +11 -0
- package/v1/index.js +14 -0
- package/v1/index.js.map +1 -0
- package/v1/module/BaseModule.d.ts +18 -0
- package/v1/module/BaseModule.js +182 -0
- package/v1/module/BaseModule.js.map +1 -0
- package/v1/module/ERC20Tokens.d.ts +3 -0
- package/v1/module/ERC20Tokens.js +87 -0
- package/v1/module/ERC20Tokens.js.map +1 -0
- package/v1/module.d.ts +3 -0
- package/v1/module.js +24 -0
- package/v1/module.js.map +1 -0
- package/v1/protocol/BaseBaseProtocol.d.ts +58 -0
- package/v1/protocol/BaseBaseProtocol.js +373 -0
- package/v1/protocol/BaseBaseProtocol.js.map +1 -0
- package/v1/protocol/BaseProtocol.d.ts +8 -0
- package/v1/protocol/BaseProtocol.js +86 -0
- package/v1/protocol/BaseProtocol.js.map +1 -0
- package/v1/protocol/erc20/ERC20Token.d.ts +20 -0
- package/v1/protocol/erc20/ERC20Token.js +198 -0
- package/v1/protocol/erc20/ERC20Token.js.map +1 -0
- package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +8 -0
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +54 -0
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-base-typed.d.ts +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-base-typed.js +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-base-typed.js.map +1 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-base.d.ts +15 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-base.js +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-base.js.map +1 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-base.d.ts +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-base.js +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-base.js.map +1 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-base-typed.json +39 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-base.json +59 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-response-base.json +19 -0
- package/v1/serializer/v3/serializer-companion.d.ts +13 -0
- package/v1/serializer/v3/serializer-companion.js +190 -0
- package/v1/serializer/v3/serializer-companion.js.map +1 -0
- package/v1/serializer/v3/validators/transaction-validator.d.ts +4 -0
- package/v1/serializer/v3/validators/transaction-validator.js +29 -0
- package/v1/serializer/v3/validators/transaction-validator.js.map +1 -0
- package/v1/types/crypto.d.ts +2 -0
- package/v1/types/crypto.js +3 -0
- package/v1/types/crypto.js.map +1 -0
- package/v1/types/protocol.d.ts +6 -0
- package/v1/types/protocol.js +3 -0
- package/v1/types/protocol.js.map +1 -0
- package/v1/types/transaction.d.ts +10 -0
- package/v1/types/transaction.js +3 -0
- package/v1/types/transaction.js.map +1 -0
- package/v1/utils/protocol.d.ts +10 -0
- package/v1/utils/protocol.js +33 -0
- package/v1/utils/protocol.js.map +1 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.erc20TokensIdentifiers = exports.erc20Tokens = void 0;
|
|
4
|
+
exports.erc20Tokens = {
|
|
5
|
+
'base-erc20-virtual': {
|
|
6
|
+
symbol: 'VIRTUAL',
|
|
7
|
+
name: 'Virtuals Protocol',
|
|
8
|
+
marketSymbol: 'virtual',
|
|
9
|
+
identifier: 'base-erc20-virtual',
|
|
10
|
+
contractAddress: '0x0b3e328455c4059EEb9e3f84b5543F74E24e7E1b',
|
|
11
|
+
decimals: 18
|
|
12
|
+
},
|
|
13
|
+
'base-erc20-brett': {
|
|
14
|
+
symbol: 'BRETT',
|
|
15
|
+
name: 'Brett',
|
|
16
|
+
marketSymbol: 'brett',
|
|
17
|
+
identifier: 'base-erc20-brett',
|
|
18
|
+
contractAddress: '0x532f27101965dd16442E59d40670FaF5eBB142E4',
|
|
19
|
+
decimals: 18
|
|
20
|
+
},
|
|
21
|
+
'base-erc20-aero': {
|
|
22
|
+
symbol: 'AERO',
|
|
23
|
+
name: 'Aerodrome',
|
|
24
|
+
marketSymbol: 'aero',
|
|
25
|
+
identifier: 'base-erc20-aero',
|
|
26
|
+
contractAddress: '0x940181a94A35A4569E4529A3CDfB74e38FD98631',
|
|
27
|
+
decimals: 18
|
|
28
|
+
},
|
|
29
|
+
'base-erc20-toshi': {
|
|
30
|
+
symbol: 'TOSHI',
|
|
31
|
+
name: 'Toshi',
|
|
32
|
+
marketSymbol: 'toshi',
|
|
33
|
+
identifier: 'base-erc20-toshi',
|
|
34
|
+
contractAddress: '0xAC1Bd2486aAf3B5C0fc3Fd868558b082a531B2B4',
|
|
35
|
+
decimals: 18
|
|
36
|
+
},
|
|
37
|
+
'base-erc20-prime': {
|
|
38
|
+
symbol: 'PRIME',
|
|
39
|
+
name: 'Echelon Prime',
|
|
40
|
+
marketSymbol: 'prime',
|
|
41
|
+
identifier: 'base-erc20-prime',
|
|
42
|
+
contractAddress: '0xfA980cEd6895AC314E7dE34Ef1bFAE90a5AdD21b',
|
|
43
|
+
decimals: 18
|
|
44
|
+
},
|
|
45
|
+
'base-erc20-zora': {
|
|
46
|
+
symbol: 'ZORA',
|
|
47
|
+
name: 'Zora',
|
|
48
|
+
marketSymbol: 'zora',
|
|
49
|
+
identifier: 'base-erc20-zora',
|
|
50
|
+
contractAddress: '0x1111111111166b7FE7bd91427724B487980aFc69',
|
|
51
|
+
decimals: 18
|
|
52
|
+
},
|
|
53
|
+
'base-erc20-usdc': {
|
|
54
|
+
symbol: 'USDC',
|
|
55
|
+
name: 'USD Coin',
|
|
56
|
+
marketSymbol: 'usdc',
|
|
57
|
+
identifier: 'base-erc20-usdc',
|
|
58
|
+
contractAddress: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
59
|
+
decimals: 6
|
|
60
|
+
},
|
|
61
|
+
'base-erc20-usdt': {
|
|
62
|
+
symbol: 'USDT',
|
|
63
|
+
name: 'Tether USD',
|
|
64
|
+
marketSymbol: 'usdt',
|
|
65
|
+
identifier: 'base-erc20-usdt',
|
|
66
|
+
contractAddress: '0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2',
|
|
67
|
+
decimals: 6
|
|
68
|
+
},
|
|
69
|
+
'base-erc20-link': {
|
|
70
|
+
symbol: 'LINK',
|
|
71
|
+
name: 'Chainlink Token',
|
|
72
|
+
marketSymbol: 'link',
|
|
73
|
+
identifier: 'base-erc20-link',
|
|
74
|
+
contractAddress: '0x88Fb150BDc53A65fe94Dea0c9BA0a6dAf8C6e196',
|
|
75
|
+
decimals: 18
|
|
76
|
+
},
|
|
77
|
+
'base-erc20-avnt': {
|
|
78
|
+
symbol: 'AVNT',
|
|
79
|
+
name: 'Avantis',
|
|
80
|
+
marketSymbol: 'avnt',
|
|
81
|
+
identifier: 'base-erc20-avnt',
|
|
82
|
+
contractAddress: '0x696F9436B67233384889472Cd7cD58A6fB5DF4f1',
|
|
83
|
+
decimals: 18
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
exports.erc20TokensIdentifiers = Object.keys(exports.erc20Tokens);
|
|
87
|
+
//# sourceMappingURL=ERC20Tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ERC20Tokens.js","sourceRoot":"","sources":["../../../src/v1/module/ERC20Tokens.ts"],"names":[],"mappings":";;;AAGa,QAAA,WAAW,GAAuC;IAC7D,oBAAoB,EAAE;QACpB,MAAM,EAAE,SAAS;QACjB,IAAI,EAAE,mBAAmB;QACzB,YAAY,EAAE,SAAS;QACvB,UAAU,EAAE,oBAAoB;QAChC,eAAe,EAAE,4CAA4C;QAC7D,QAAQ,EAAE,EAAE;KACb;IACD,kBAAkB,EAAE;QAClB,MAAM,EAAE,OAAO;QACf,IAAI,EAAE,OAAO;QACb,YAAY,EAAE,OAAO;QACrB,UAAU,EAAE,kBAAkB;QAC9B,eAAe,EAAE,4CAA4C;QAC7D,QAAQ,EAAE,EAAE;KACb;IACD,iBAAiB,EAAE;QACjB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,WAAW;QACjB,YAAY,EAAE,MAAM;QACpB,UAAU,EAAE,iBAAiB;QAC7B,eAAe,EAAE,4CAA4C;QAC7D,QAAQ,EAAE,EAAE;KACb;IACD,kBAAkB,EAAE;QAClB,MAAM,EAAE,OAAO;QACf,IAAI,EAAE,OAAO;QACb,YAAY,EAAE,OAAO;QACrB,UAAU,EAAE,kBAAkB;QAC9B,eAAe,EAAE,4CAA4C;QAC7D,QAAQ,EAAE,EAAE;KACb;IACD,kBAAkB,EAAE;QAClB,MAAM,EAAE,OAAO;QACf,IAAI,EAAE,eAAe;QACrB,YAAY,EAAE,OAAO;QACrB,UAAU,EAAE,kBAAkB;QAC9B,eAAe,EAAE,4CAA4C;QAC7D,QAAQ,EAAE,EAAE;KACb;IACD,iBAAiB,EAAE;QACjB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,MAAM;QACZ,YAAY,EAAE,MAAM;QACpB,UAAU,EAAE,iBAAiB;QAC7B,eAAe,EAAE,4CAA4C;QAC7D,QAAQ,EAAE,EAAE;KACb;IACD,iBAAiB,EAAE;QACjB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,UAAU;QAChB,YAAY,EAAE,MAAM;QACpB,UAAU,EAAE,iBAAiB;QAC7B,eAAe,EAAE,4CAA4C;QAC7D,QAAQ,EAAE,CAAC;KACZ;IACD,iBAAiB,EAAE;QACjB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,YAAY;QAClB,YAAY,EAAE,MAAM;QACpB,UAAU,EAAE,iBAAiB;QAC7B,eAAe,EAAE,4CAA4C;QAC7D,QAAQ,EAAE,CAAC;KACZ;IACD,iBAAiB,EAAE;QACjB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,iBAAiB;QACvB,YAAY,EAAE,MAAM;QACpB,UAAU,EAAE,iBAAiB;QAC7B,eAAe,EAAE,4CAA4C;QAC7D,QAAQ,EAAE,EAAE;KACb;IACD,iBAAiB,EAAE;QACjB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,MAAM;QACpB,UAAU,EAAE,iBAAiB;QAC7B,eAAe,EAAE,4CAA4C;QAC7D,QAAQ,EAAE,EAAE;KACb;CACF,CAAA;AAEY,QAAA,sBAAsB,GAAa,MAAM,CAAC,IAAI,CAAC,mBAAW,CAAC,CAAA"}
|
package/v1/module.d.ts
ADDED
package/v1/module.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.create = void 0;
|
|
18
|
+
var BaseModule_1 = require("./module/BaseModule");
|
|
19
|
+
__exportStar(require("./index"), exports);
|
|
20
|
+
function create() {
|
|
21
|
+
return new BaseModule_1.BaseModule();
|
|
22
|
+
}
|
|
23
|
+
exports.create = create;
|
|
24
|
+
//# sourceMappingURL=module.js.map
|
package/v1/module.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/v1/module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,kDAAgD;AAEhD,0CAAuB;AAEvB,SAAgB,MAAM;IACpB,OAAO,IAAI,uBAAU,EAAE,CAAA;AACzB,CAAC;AAFD,wBAEC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { EthereumBaseProtocolImpl, EthereumUnits } from '@airgap/ethereum/v1';
|
|
2
|
+
import { Address, AirGapProtocol, AirGapTransaction, AirGapTransactionStatus, AirGapTransactionsWithCursor, Amount, Balance, CryptoDerivative, ExtendedKeyPair, ExtendedPublicKey, ExtendedSecretKey, FeeDefaults, KeyPair, ProtocolMetadata, ProtocolUnitsMetadata, PublicKey, SecretKey, Signature, TransactionFullConfiguration, TransactionDetails, WalletConnectRequest, TokenDetails } from '@airgap/module-kit';
|
|
3
|
+
import { BaseInfoClient } from '../client/info/BaseInfoClient';
|
|
4
|
+
import { BaseNodeClient } from '../client/node/BaseNodeClient';
|
|
5
|
+
import { BaseCryptoConfiguration } from '../types/crypto';
|
|
6
|
+
import { BaseProtocolNetwork, BaseProtocolOptions } from '../types/protocol';
|
|
7
|
+
import { BaseSignedTransaction, BaseTransactionCursor, BaseUnsignedTransaction } from '../types/transaction';
|
|
8
|
+
export interface BaseBaseProtocol<_Units extends string = EthereumUnits> extends AirGapProtocol<{
|
|
9
|
+
AddressResult: Address;
|
|
10
|
+
ProtocolNetwork: BaseProtocolNetwork;
|
|
11
|
+
CryptoConfiguration: BaseCryptoConfiguration;
|
|
12
|
+
Units: _Units;
|
|
13
|
+
FeeUnits: EthereumUnits;
|
|
14
|
+
FeeEstimation: FeeDefaults<EthereumUnits>;
|
|
15
|
+
SignedTransaction: BaseSignedTransaction;
|
|
16
|
+
UnsignedTransaction: BaseUnsignedTransaction;
|
|
17
|
+
TransactionCursor: BaseTransactionCursor;
|
|
18
|
+
}, 'Bip32', 'Crypto', 'FetchDataForAddress', 'FetchDataForMultipleAddresses', 'GetTokenBalances', 'TransactionStatusChecker', 'WalletConnect'> {
|
|
19
|
+
}
|
|
20
|
+
export declare abstract class BaseBaseProtocolImpl<_Units extends string = EthereumUnits, _EthereumProtocol extends EthereumBaseProtocolImpl<_Units, BaseProtocolNetwork> = EthereumBaseProtocolImpl<_Units, BaseProtocolNetwork>, _Options extends BaseProtocolOptions = BaseProtocolOptions> implements BaseBaseProtocol<_Units> {
|
|
21
|
+
protected readonly ethereumProtocol: _EthereumProtocol;
|
|
22
|
+
protected readonly nodeClient: BaseNodeClient;
|
|
23
|
+
protected readonly infoClient: BaseInfoClient;
|
|
24
|
+
protected readonly options: _Options;
|
|
25
|
+
protected constructor(ethereumProtocol: _EthereumProtocol, nodeClient: BaseNodeClient, infoClient: BaseInfoClient, options: _Options);
|
|
26
|
+
protected readonly units: ProtocolUnitsMetadata<_Units>;
|
|
27
|
+
protected readonly feeUnits: ProtocolUnitsMetadata<EthereumUnits>;
|
|
28
|
+
getMetadata(): Promise<ProtocolMetadata<_Units, EthereumUnits>>;
|
|
29
|
+
getAddressFromPublicKey(publicKey: PublicKey | ExtendedPublicKey): Promise<string>;
|
|
30
|
+
deriveFromExtendedPublicKey(extendedPublicKey: ExtendedPublicKey, visibilityIndex: number, addressIndex: number): Promise<PublicKey>;
|
|
31
|
+
getDetailsFromTransaction(transaction: BaseUnsignedTransaction | BaseSignedTransaction, publicKey: PublicKey | ExtendedPublicKey): Promise<AirGapTransaction<_Units, EthereumUnits>[]>;
|
|
32
|
+
verifyMessageWithPublicKey(message: string, signature: Signature, publicKey: PublicKey | ExtendedPublicKey): Promise<boolean>;
|
|
33
|
+
encryptAsymmetricWithPublicKey(payload: string, publicKey: PublicKey | ExtendedPublicKey): Promise<string>;
|
|
34
|
+
getCryptoConfiguration(): Promise<BaseCryptoConfiguration>;
|
|
35
|
+
getKeyPairFromDerivative(derivative: CryptoDerivative): Promise<KeyPair>;
|
|
36
|
+
getExtendedKeyPairFromDerivative(derivative: CryptoDerivative): Promise<ExtendedKeyPair>;
|
|
37
|
+
deriveFromExtendedSecretKey(extendedSecretKey: ExtendedSecretKey, visibilityIndex: number, addressIndex: number): Promise<SecretKey>;
|
|
38
|
+
signTransactionWithSecretKey(transaction: BaseUnsignedTransaction, secretKey: SecretKey | ExtendedSecretKey): Promise<BaseSignedTransaction>;
|
|
39
|
+
signMessageWithKeyPair(message: string, keyPair: KeyPair | ExtendedKeyPair): Promise<Signature>;
|
|
40
|
+
decryptAsymmetricWithKeyPair(payload: string, keyPair: KeyPair | ExtendedKeyPair): Promise<string>;
|
|
41
|
+
encryptAESWithSecretKey(payload: string, secretKey: SecretKey | ExtendedSecretKey): Promise<string>;
|
|
42
|
+
decryptAESWithSecretKey(payload: string, secretKey: SecretKey | ExtendedSecretKey): Promise<string>;
|
|
43
|
+
getNetwork(): Promise<BaseProtocolNetwork>;
|
|
44
|
+
getTransactionsForPublicKey(publicKey: PublicKey | ExtendedPublicKey, limit: number, cursor?: BaseTransactionCursor): Promise<AirGapTransactionsWithCursor<BaseTransactionCursor, _Units, EthereumUnits>>;
|
|
45
|
+
getTransactionsForAddress(address: string, limit: number, cursor?: BaseTransactionCursor): Promise<AirGapTransactionsWithCursor<BaseTransactionCursor, _Units, EthereumUnits>>;
|
|
46
|
+
getTransactionsForAddresses(addresses: string[], limit: number, cursor?: BaseTransactionCursor): Promise<AirGapTransactionsWithCursor<BaseTransactionCursor, _Units, EthereumUnits>>;
|
|
47
|
+
getTransactionStatus(transactionIds: string[]): Promise<Record<string, AirGapTransactionStatus>>;
|
|
48
|
+
getBalanceOfPublicKey(publicKey: PublicKey | ExtendedPublicKey): Promise<Balance<_Units>>;
|
|
49
|
+
getBalanceOfAddress(address: string): Promise<Balance<_Units>>;
|
|
50
|
+
getBalanceOfAddresses(addresses: string[]): Promise<Balance<_Units>>;
|
|
51
|
+
getTokenBalancesOfPublicKey(publicKey: PublicKey | ExtendedPublicKey, tokens: TokenDetails[]): Promise<Record<string, Amount>>;
|
|
52
|
+
getTransactionMaxAmountWithPublicKey(publicKey: PublicKey | ExtendedPublicKey, to: string[], configuration?: TransactionFullConfiguration<EthereumUnits>): Promise<Amount<_Units>>;
|
|
53
|
+
getTransactionFeeWithPublicKey(publicKey: PublicKey | ExtendedPublicKey, details: TransactionDetails<_Units>[]): Promise<FeeDefaults<EthereumUnits>>;
|
|
54
|
+
prepareTransactionWithPublicKey(publicKey: PublicKey | ExtendedPublicKey, details: TransactionDetails<_Units>[], configuration?: TransactionFullConfiguration<EthereumUnits>): Promise<BaseUnsignedTransaction>;
|
|
55
|
+
getWalletConnectChain(): Promise<string>;
|
|
56
|
+
prepareWalletConnectTransactionWithPublicKey(publicKey: PublicKey | ExtendedPublicKey, request: WalletConnectRequest): Promise<BaseUnsignedTransaction>;
|
|
57
|
+
broadcastTransaction(transaction: BaseSignedTransaction): Promise<string>;
|
|
58
|
+
}
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
exports.BaseBaseProtocolImpl = void 0;
|
|
54
|
+
var bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
|
|
55
|
+
var v1_1 = require("@airgap/ethereum/v1");
|
|
56
|
+
var module_kit_1 = require("@airgap/module-kit");
|
|
57
|
+
// Implementation
|
|
58
|
+
var BaseBaseProtocolImpl = /** @class */ (function () {
|
|
59
|
+
function BaseBaseProtocolImpl(ethereumProtocol, nodeClient, infoClient, options) {
|
|
60
|
+
this.ethereumProtocol = ethereumProtocol;
|
|
61
|
+
this.nodeClient = nodeClient;
|
|
62
|
+
this.infoClient = infoClient;
|
|
63
|
+
this.options = options;
|
|
64
|
+
this.units = this.ethereumProtocol.units;
|
|
65
|
+
this.feeUnits = this.ethereumProtocol.feeUnits;
|
|
66
|
+
}
|
|
67
|
+
BaseBaseProtocolImpl.prototype.getMetadata = function () {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
69
|
+
return __generator(this, function (_a) {
|
|
70
|
+
return [2 /*return*/, this.ethereumProtocol.getMetadata()];
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
BaseBaseProtocolImpl.prototype.getAddressFromPublicKey = function (publicKey) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
76
|
+
return __generator(this, function (_a) {
|
|
77
|
+
return [2 /*return*/, this.ethereumProtocol.getAddressFromPublicKey(publicKey)];
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
BaseBaseProtocolImpl.prototype.deriveFromExtendedPublicKey = function (extendedPublicKey, visibilityIndex, addressIndex) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
83
|
+
return __generator(this, function (_a) {
|
|
84
|
+
return [2 /*return*/, this.ethereumProtocol.deriveFromExtendedPublicKey(extendedPublicKey, visibilityIndex, addressIndex)];
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
BaseBaseProtocolImpl.prototype.getDetailsFromTransaction = function (transaction, publicKey) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
90
|
+
var ethereumDetails, l1DataFee, l1DataFeePerTransaction;
|
|
91
|
+
var _this = this;
|
|
92
|
+
return __generator(this, function (_a) {
|
|
93
|
+
switch (_a.label) {
|
|
94
|
+
case 0: return [4 /*yield*/, this.ethereumProtocol.getDetailsFromTransaction(transaction, publicKey)];
|
|
95
|
+
case 1:
|
|
96
|
+
ethereumDetails = _a.sent();
|
|
97
|
+
l1DataFee = transaction.type === 'signed' ? transaction.l1DataFee : transaction.ethereumType === 'raw' ? transaction.l1DataFee : undefined;
|
|
98
|
+
if (l1DataFee === undefined) {
|
|
99
|
+
return [2 /*return*/, ethereumDetails];
|
|
100
|
+
}
|
|
101
|
+
l1DataFeePerTransaction = new bignumber_1.default(l1DataFee).div(ethereumDetails.length);
|
|
102
|
+
return [2 /*return*/, ethereumDetails.map(function (details) {
|
|
103
|
+
var feeBlockchain = (0, module_kit_1.newAmount)(details.fee).blockchain(_this.feeUnits);
|
|
104
|
+
return __assign(__assign({}, details), { fee: (0, module_kit_1.newAmount)(l1DataFeePerTransaction.plus(feeBlockchain.value), 'blockchain') });
|
|
105
|
+
})];
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
BaseBaseProtocolImpl.prototype.verifyMessageWithPublicKey = function (message, signature, publicKey) {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
112
|
+
return __generator(this, function (_a) {
|
|
113
|
+
return [2 /*return*/, this.ethereumProtocol.verifyMessageWithPublicKey(message, signature, publicKey)];
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
BaseBaseProtocolImpl.prototype.encryptAsymmetricWithPublicKey = function (payload, publicKey) {
|
|
118
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
119
|
+
return __generator(this, function (_a) {
|
|
120
|
+
return [2 /*return*/, this.ethereumProtocol.encryptAsymmetricWithPublicKey(payload, publicKey)];
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
// Offline
|
|
125
|
+
BaseBaseProtocolImpl.prototype.getCryptoConfiguration = function () {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
127
|
+
return __generator(this, function (_a) {
|
|
128
|
+
return [2 /*return*/, this.ethereumProtocol.getCryptoConfiguration()];
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
BaseBaseProtocolImpl.prototype.getKeyPairFromDerivative = function (derivative) {
|
|
133
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
134
|
+
return __generator(this, function (_a) {
|
|
135
|
+
return [2 /*return*/, this.ethereumProtocol.getKeyPairFromDerivative(derivative)];
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
BaseBaseProtocolImpl.prototype.getExtendedKeyPairFromDerivative = function (derivative) {
|
|
140
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
141
|
+
return __generator(this, function (_a) {
|
|
142
|
+
return [2 /*return*/, this.ethereumProtocol.getExtendedKeyPairFromDerivative(derivative)];
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
BaseBaseProtocolImpl.prototype.deriveFromExtendedSecretKey = function (extendedSecretKey, visibilityIndex, addressIndex) {
|
|
147
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
148
|
+
return __generator(this, function (_a) {
|
|
149
|
+
return [2 /*return*/, this.ethereumProtocol.deriveFromExtendedSecretKey(extendedSecretKey, visibilityIndex, addressIndex)];
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
BaseBaseProtocolImpl.prototype.signTransactionWithSecretKey = function (transaction, secretKey) {
|
|
154
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
155
|
+
var ethereumTransaction;
|
|
156
|
+
return __generator(this, function (_a) {
|
|
157
|
+
switch (_a.label) {
|
|
158
|
+
case 0: return [4 /*yield*/, this.ethereumProtocol.signTransactionWithSecretKey(transaction, secretKey)];
|
|
159
|
+
case 1:
|
|
160
|
+
ethereumTransaction = _a.sent();
|
|
161
|
+
return [2 /*return*/, transaction.ethereumType === 'raw'
|
|
162
|
+
? (0, module_kit_1.newSignedTransaction)(__assign(__assign({}, ethereumTransaction), { l1DataFee: transaction.l1DataFee }))
|
|
163
|
+
: ethereumTransaction];
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
BaseBaseProtocolImpl.prototype.signMessageWithKeyPair = function (message, keyPair) {
|
|
169
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
170
|
+
return __generator(this, function (_a) {
|
|
171
|
+
return [2 /*return*/, this.ethereumProtocol.signMessageWithKeyPair(message, keyPair)];
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
BaseBaseProtocolImpl.prototype.decryptAsymmetricWithKeyPair = function (payload, keyPair) {
|
|
176
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
177
|
+
return __generator(this, function (_a) {
|
|
178
|
+
return [2 /*return*/, this.ethereumProtocol.decryptAsymmetricWithKeyPair(payload, keyPair)];
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
BaseBaseProtocolImpl.prototype.encryptAESWithSecretKey = function (payload, secretKey) {
|
|
183
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
184
|
+
return __generator(this, function (_a) {
|
|
185
|
+
return [2 /*return*/, this.ethereumProtocol.encryptAESWithSecretKey(payload, secretKey)];
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
};
|
|
189
|
+
BaseBaseProtocolImpl.prototype.decryptAESWithSecretKey = function (payload, secretKey) {
|
|
190
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
191
|
+
return __generator(this, function (_a) {
|
|
192
|
+
return [2 /*return*/, this.ethereumProtocol.decryptAESWithSecretKey(payload, secretKey)];
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
// Online
|
|
197
|
+
BaseBaseProtocolImpl.prototype.getNetwork = function () {
|
|
198
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
199
|
+
return __generator(this, function (_a) {
|
|
200
|
+
return [2 /*return*/, this.ethereumProtocol.getNetwork()];
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
BaseBaseProtocolImpl.prototype.getTransactionsForPublicKey = function (publicKey, limit, cursor) {
|
|
205
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
206
|
+
return __generator(this, function (_a) {
|
|
207
|
+
return [2 /*return*/, this.ethereumProtocol.getTransactionsForPublicKey(publicKey, limit, cursor)];
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
};
|
|
211
|
+
BaseBaseProtocolImpl.prototype.getTransactionsForAddress = function (address, limit, cursor) {
|
|
212
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
213
|
+
return __generator(this, function (_a) {
|
|
214
|
+
return [2 /*return*/, this.ethereumProtocol.getTransactionsForAddress(address, limit, cursor)];
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
BaseBaseProtocolImpl.prototype.getTransactionsForAddresses = function (addresses, limit, cursor) {
|
|
219
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
220
|
+
return __generator(this, function (_a) {
|
|
221
|
+
return [2 /*return*/, this.ethereumProtocol.getTransactionsForAddresses(addresses, limit, cursor)];
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
};
|
|
225
|
+
BaseBaseProtocolImpl.prototype.getTransactionStatus = function (transactionIds) {
|
|
226
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
227
|
+
return __generator(this, function (_a) {
|
|
228
|
+
return [2 /*return*/, this.ethereumProtocol.getTransactionStatus(transactionIds)];
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
};
|
|
232
|
+
BaseBaseProtocolImpl.prototype.getBalanceOfPublicKey = function (publicKey) {
|
|
233
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
234
|
+
return __generator(this, function (_a) {
|
|
235
|
+
return [2 /*return*/, this.ethereumProtocol.getBalanceOfPublicKey(publicKey)];
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
};
|
|
239
|
+
BaseBaseProtocolImpl.prototype.getBalanceOfAddress = function (address) {
|
|
240
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
241
|
+
return __generator(this, function (_a) {
|
|
242
|
+
return [2 /*return*/, this.ethereumProtocol.getBalanceOfAddress(address)];
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
BaseBaseProtocolImpl.prototype.getBalanceOfAddresses = function (addresses) {
|
|
247
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
248
|
+
return __generator(this, function (_a) {
|
|
249
|
+
return [2 /*return*/, this.ethereumProtocol.getBalanceOfAddresses(addresses)];
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
};
|
|
253
|
+
BaseBaseProtocolImpl.prototype.getTokenBalancesOfPublicKey = function (publicKey, tokens) {
|
|
254
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
255
|
+
return __generator(this, function (_a) {
|
|
256
|
+
return [2 /*return*/, this.ethereumProtocol.getTokenBalancesOfPublicKey(publicKey, tokens)];
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
};
|
|
260
|
+
BaseBaseProtocolImpl.prototype.getTransactionMaxAmountWithPublicKey = function (publicKey, to, configuration) {
|
|
261
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
262
|
+
var _a, metadata, ethereumMaxAmount, maxAmountBlockchain, maxAmountPerRecipient, ethereumTransaction, l1Fee;
|
|
263
|
+
return __generator(this, function (_b) {
|
|
264
|
+
switch (_b.label) {
|
|
265
|
+
case 0: return [4 /*yield*/, Promise.all([
|
|
266
|
+
this.getMetadata(),
|
|
267
|
+
this.ethereumProtocol.getTransactionMaxAmountWithPublicKey(publicKey, to, configuration)
|
|
268
|
+
])];
|
|
269
|
+
case 1:
|
|
270
|
+
_a = _b.sent(), metadata = _a[0], ethereumMaxAmount = _a[1];
|
|
271
|
+
maxAmountBlockchain = new bignumber_1.default((0, module_kit_1.newAmount)(ethereumMaxAmount).blockchain(metadata.units).value);
|
|
272
|
+
maxAmountPerRecipient = maxAmountBlockchain.div(to.length);
|
|
273
|
+
return [4 /*yield*/, this.ethereumProtocol.prepareTransactionWithPublicKey(publicKey, to.map(function (recipient) { return ({
|
|
274
|
+
to: recipient,
|
|
275
|
+
amount: (0, module_kit_1.newAmount)(maxAmountPerRecipient, 'blockchain')
|
|
276
|
+
}); }), configuration)];
|
|
277
|
+
case 2:
|
|
278
|
+
ethereumTransaction = _b.sent();
|
|
279
|
+
return [4 /*yield*/, this.nodeClient.getL1Fee(this.options.network.gasPriceOracleAddress, ethereumTransaction)];
|
|
280
|
+
case 3:
|
|
281
|
+
l1Fee = _b.sent();
|
|
282
|
+
if (maxAmountBlockchain.lte(l1Fee)) {
|
|
283
|
+
return [2 /*return*/, (0, module_kit_1.newAmount)(0, 'blockchain')];
|
|
284
|
+
}
|
|
285
|
+
return [2 /*return*/, (0, module_kit_1.newAmount)(maxAmountBlockchain.minus(l1Fee), 'blockchain')];
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
};
|
|
290
|
+
BaseBaseProtocolImpl.prototype.getTransactionFeeWithPublicKey = function (publicKey, details) {
|
|
291
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
292
|
+
var l2Fee, ethereumTransaction, l1Fee;
|
|
293
|
+
return __generator(this, function (_a) {
|
|
294
|
+
switch (_a.label) {
|
|
295
|
+
case 0: return [4 /*yield*/, this.ethereumProtocol.getTransactionFeeWithPublicKey(publicKey, details)];
|
|
296
|
+
case 1:
|
|
297
|
+
l2Fee = _a.sent();
|
|
298
|
+
return [4 /*yield*/, this.ethereumProtocol.prepareTransactionWithPublicKey(publicKey, details, { fee: l2Fee.medium })];
|
|
299
|
+
case 2:
|
|
300
|
+
ethereumTransaction = _a.sent();
|
|
301
|
+
return [4 /*yield*/, this.nodeClient.getL1Fee(this.options.network.gasPriceOracleAddress, ethereumTransaction)];
|
|
302
|
+
case 3:
|
|
303
|
+
l1Fee = _a.sent();
|
|
304
|
+
return [2 /*return*/, {
|
|
305
|
+
low: (0, module_kit_1.newAmount)(l1Fee.plus((0, module_kit_1.newAmount)(l2Fee.low).blockchain(this.feeUnits).value), 'blockchain'),
|
|
306
|
+
medium: (0, module_kit_1.newAmount)(l1Fee.plus((0, module_kit_1.newAmount)(l2Fee.medium).blockchain(this.feeUnits).value), 'blockchain'),
|
|
307
|
+
high: (0, module_kit_1.newAmount)(l1Fee.plus((0, module_kit_1.newAmount)(l2Fee.high).blockchain(this.feeUnits).value), 'blockchain')
|
|
308
|
+
}];
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
};
|
|
313
|
+
BaseBaseProtocolImpl.prototype.prepareTransactionWithPublicKey = function (publicKey, details, configuration) {
|
|
314
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
315
|
+
var ethereumTransaction, l1Gas, gasLimit, gasPrice, totalGas, l2Gas, newGasPrice;
|
|
316
|
+
return __generator(this, function (_a) {
|
|
317
|
+
switch (_a.label) {
|
|
318
|
+
case 0: return [4 /*yield*/, this.ethereumProtocol.prepareTransactionWithPublicKey(publicKey, details, configuration)];
|
|
319
|
+
case 1:
|
|
320
|
+
ethereumTransaction = _a.sent();
|
|
321
|
+
if (ethereumTransaction.ethereumType === 'typed') {
|
|
322
|
+
return [2 /*return*/, ethereumTransaction];
|
|
323
|
+
}
|
|
324
|
+
return [4 /*yield*/, this.nodeClient.getL1Fee(this.options.network.gasPriceOracleAddress, ethereumTransaction)];
|
|
325
|
+
case 2:
|
|
326
|
+
l1Gas = _a.sent();
|
|
327
|
+
gasLimit = v1_1.EthereumUtils.hexToNumber(ethereumTransaction.gasLimit);
|
|
328
|
+
gasPrice = v1_1.EthereumUtils.hexToNumber(ethereumTransaction.gasPrice);
|
|
329
|
+
totalGas = gasPrice.times(gasLimit);
|
|
330
|
+
l2Gas = totalGas.minus(l1Gas).abs();
|
|
331
|
+
newGasPrice = l2Gas.div(gasLimit).integerValue(bignumber_1.default.ROUND_CEIL);
|
|
332
|
+
return [2 /*return*/, (0, module_kit_1.newUnsignedTransaction)(__assign(__assign({}, ethereumTransaction), { gasPrice: v1_1.EthereumUtils.toHex(newGasPrice.toFixed()), l1DataFee: l1Gas.toFixed() }))];
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
};
|
|
337
|
+
BaseBaseProtocolImpl.prototype.getWalletConnectChain = function () {
|
|
338
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
339
|
+
return __generator(this, function (_a) {
|
|
340
|
+
return [2 /*return*/, this.ethereumProtocol.getWalletConnectChain()];
|
|
341
|
+
});
|
|
342
|
+
});
|
|
343
|
+
};
|
|
344
|
+
BaseBaseProtocolImpl.prototype.prepareWalletConnectTransactionWithPublicKey = function (publicKey, request) {
|
|
345
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
346
|
+
var ethereumTransaction, l1Gas;
|
|
347
|
+
return __generator(this, function (_a) {
|
|
348
|
+
switch (_a.label) {
|
|
349
|
+
case 0: return [4 /*yield*/, this.ethereumProtocol.prepareWalletConnectTransactionWithPublicKey(publicKey, request)];
|
|
350
|
+
case 1:
|
|
351
|
+
ethereumTransaction = _a.sent();
|
|
352
|
+
if (ethereumTransaction.ethereumType === 'typed') {
|
|
353
|
+
return [2 /*return*/, ethereumTransaction];
|
|
354
|
+
}
|
|
355
|
+
return [4 /*yield*/, this.nodeClient.getL1Fee(this.options.network.gasPriceOracleAddress, ethereumTransaction)];
|
|
356
|
+
case 2:
|
|
357
|
+
l1Gas = _a.sent();
|
|
358
|
+
return [2 /*return*/, (0, module_kit_1.newUnsignedTransaction)(__assign(__assign({}, ethereumTransaction), { l1DataFee: l1Gas.toFixed() }))];
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
};
|
|
363
|
+
BaseBaseProtocolImpl.prototype.broadcastTransaction = function (transaction) {
|
|
364
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
365
|
+
return __generator(this, function (_a) {
|
|
366
|
+
return [2 /*return*/, this.ethereumProtocol.broadcastTransaction(transaction)];
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
};
|
|
370
|
+
return BaseBaseProtocolImpl;
|
|
371
|
+
}());
|
|
372
|
+
exports.BaseBaseProtocolImpl = BaseBaseProtocolImpl;
|
|
373
|
+
//# sourceMappingURL=BaseBaseProtocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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GAAG,SAA+F;wBAE7G,sBAAO,IAAA,mCAAsB,wBACxB,mBAAmB,KACtB,SAAS,EAAE,KAAK,CAAC,OAAO,EAAE,IAC1B,EAAA;;;;KACH;IAEY,mDAAoB,GAAjC,UAAkC,WAAkC;;;gBAClE,sBAAO,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,WAAW,CAAC,EAAA;;;KAC/D;IACH,2BAAC;AAAD,CAAC,AAvRD,IAuRC;AAvRqB,oDAAoB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RecursivePartial } from '@airgap/module-kit';
|
|
2
|
+
import { BaseProtocolNetwork, BaseProtocolOptions } from '../types/protocol';
|
|
3
|
+
import { BaseBaseProtocol } from './BaseBaseProtocol';
|
|
4
|
+
export interface BaseProtocol extends BaseBaseProtocol {
|
|
5
|
+
}
|
|
6
|
+
export declare function createBaseProtocol(options?: RecursivePartial<BaseProtocolOptions>): BaseProtocol;
|
|
7
|
+
export declare const BASE_MAINNET_PROTOCOL_NETWORK: BaseProtocolNetwork;
|
|
8
|
+
export declare function createBaseProtocolOptions(network?: Partial<BaseProtocolNetwork>): BaseProtocolOptions;
|