@massalabs/wallet-provider 1.2.1-dev.20230801093549 → 1.2.1-dev.20230803141012
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/bundle.js +5662 -5204
- package/bundle.min.js +3 -0
- package/dist/cmd/account/Account.d.ts +103 -0
- package/dist/cmd/account/Account.d.ts.map +1 -0
- package/dist/cmd/account/Account.js +179 -0
- package/dist/cmd/account/Account.js.map +1 -0
- package/dist/cmd/account/AccountBalance.d.ts +14 -0
- package/dist/cmd/account/AccountBalance.d.ts.map +1 -0
- package/dist/cmd/account/AccountBalance.js +3 -0
- package/dist/cmd/account/AccountBalance.js.map +1 -0
- package/dist/cmd/account/AccountSign.d.ts +16 -0
- package/dist/cmd/account/AccountSign.d.ts.map +1 -0
- package/dist/cmd/account/AccountSign.js +3 -0
- package/dist/cmd/account/AccountSign.js.map +1 -0
- package/dist/cmd/account/IAccount.d.ts +20 -0
- package/dist/cmd/account/IAccount.d.ts.map +1 -0
- package/dist/cmd/account/IAccount.js +3 -0
- package/dist/cmd/account/IAccount.js.map +1 -0
- package/dist/cmd/account/IAccountCallSCRequest.d.ts +25 -0
- package/dist/cmd/account/IAccountCallSCRequest.d.ts.map +1 -0
- package/dist/cmd/account/IAccountCallSCRequest.js +3 -0
- package/dist/cmd/account/IAccountCallSCRequest.js.map +1 -0
- package/dist/cmd/account/IAccountDetails.d.ts +8 -0
- package/dist/cmd/account/IAccountDetails.d.ts.map +1 -0
- package/dist/cmd/account/IAccountDetails.js +3 -0
- package/dist/cmd/account/IAccountDetails.js.map +1 -0
- package/dist/cmd/account/IAccountRolls.d.ts +8 -0
- package/dist/cmd/account/IAccountRolls.d.ts.map +1 -0
- package/dist/cmd/account/IAccountRolls.js +3 -0
- package/dist/cmd/account/IAccountRolls.js.map +1 -0
- package/dist/cmd/account/IAccountSendTransaction.d.ts +9 -0
- package/dist/cmd/account/IAccountSendTransaction.d.ts.map +1 -0
- package/dist/cmd/account/IAccountSendTransaction.js +3 -0
- package/dist/cmd/account/IAccountSendTransaction.js.map +1 -0
- package/dist/cmd/account/index.d.ts +9 -0
- package/dist/cmd/account/index.d.ts.map +1 -0
- package/dist/cmd/account/index.js +6 -0
- package/dist/cmd/account/index.js.map +1 -0
- package/dist/cmd/connector/Connector.d.ts +87 -0
- package/dist/cmd/connector/Connector.d.ts.map +1 -0
- package/dist/cmd/connector/Connector.js +173 -0
- package/dist/cmd/connector/Connector.js.map +1 -0
- package/dist/cmd/connector/ICustomEventMessageRequest.d.ts +10 -0
- package/dist/cmd/connector/ICustomEventMessageRequest.d.ts.map +1 -0
- package/dist/cmd/connector/ICustomEventMessageRequest.js +3 -0
- package/dist/cmd/connector/ICustomEventMessageRequest.js.map +1 -0
- package/dist/cmd/connector/ICustomEventMessageResponse.d.ts +11 -0
- package/dist/cmd/connector/ICustomEventMessageResponse.d.ts.map +1 -0
- package/dist/cmd/connector/ICustomEventMessageResponse.js +3 -0
- package/dist/cmd/connector/ICustomEventMessageResponse.js.map +1 -0
- package/dist/cmd/connector/IRegisterEvent.d.ts +8 -0
- package/dist/cmd/connector/IRegisterEvent.d.ts.map +1 -0
- package/dist/cmd/connector/IRegisterEvent.js +3 -0
- package/dist/cmd/connector/IRegisterEvent.js.map +1 -0
- package/dist/cmd/connector/index.d.ts +5 -0
- package/dist/cmd/connector/index.d.ts.map +1 -0
- package/dist/cmd/connector/index.js +7 -0
- package/dist/cmd/connector/index.js.map +1 -0
- package/dist/cmd/index.d.ts +48 -0
- package/dist/cmd/index.d.ts.map +1 -0
- package/dist/cmd/index.js +89 -0
- package/dist/cmd/index.js.map +1 -0
- package/dist/cmd/massaStation/MassaStationAccount.d.ts +103 -0
- package/dist/cmd/massaStation/MassaStationAccount.d.ts.map +1 -0
- package/dist/cmd/massaStation/MassaStationAccount.js +312 -0
- package/dist/cmd/massaStation/MassaStationAccount.js.map +1 -0
- package/dist/cmd/massaStation/MassaStationDiscovery.d.ts +57 -0
- package/dist/cmd/massaStation/MassaStationDiscovery.d.ts.map +1 -0
- package/dist/cmd/massaStation/MassaStationDiscovery.js +80 -0
- package/dist/cmd/massaStation/MassaStationDiscovery.js.map +1 -0
- package/dist/cmd/massaStation/MassaStationProvider.d.ts +91 -0
- package/dist/cmd/massaStation/MassaStationProvider.d.ts.map +1 -0
- package/dist/cmd/massaStation/MassaStationProvider.js +193 -0
- package/dist/cmd/massaStation/MassaStationProvider.js.map +1 -0
- package/dist/cmd/massaStation/RequestHandler.d.ts +47 -0
- package/dist/cmd/massaStation/RequestHandler.d.ts.map +1 -0
- package/dist/cmd/massaStation/RequestHandler.js +133 -0
- package/dist/cmd/massaStation/RequestHandler.js.map +1 -0
- package/dist/cmd/provider/AccountDeletion.d.ts +24 -0
- package/dist/cmd/provider/AccountDeletion.d.ts.map +1 -0
- package/dist/cmd/provider/AccountDeletion.js +14 -0
- package/dist/cmd/provider/AccountDeletion.js.map +1 -0
- package/dist/cmd/provider/AccountImport.d.ts +26 -0
- package/dist/cmd/provider/AccountImport.d.ts.map +1 -0
- package/dist/cmd/provider/AccountImport.js +14 -0
- package/dist/cmd/provider/AccountImport.js.map +1 -0
- package/dist/cmd/provider/AccoutGeneration.d.ts +8 -0
- package/dist/cmd/provider/AccoutGeneration.d.ts.map +1 -0
- package/dist/cmd/provider/AccoutGeneration.js +3 -0
- package/dist/cmd/provider/AccoutGeneration.js.map +1 -0
- package/dist/cmd/provider/IProvider.d.ts +16 -0
- package/dist/cmd/provider/IProvider.d.ts.map +1 -0
- package/dist/cmd/provider/IProvider.js +3 -0
- package/dist/cmd/provider/IProvider.js.map +1 -0
- package/dist/cmd/provider/Provider.d.ts +68 -0
- package/dist/cmd/provider/Provider.d.ts.map +1 -0
- package/dist/cmd/provider/Provider.js +126 -0
- package/dist/cmd/provider/Provider.js.map +1 -0
- package/dist/cmd/provider/index.d.ts +5 -0
- package/dist/cmd/provider/index.d.ts.map +1 -0
- package/dist/cmd/provider/index.js +10 -0
- package/dist/cmd/provider/index.js.map +1 -0
- package/dist/cmd/utils/argsToBase64.d.ts +16 -0
- package/dist/cmd/utils/argsToBase64.d.ts.map +1 -0
- package/dist/cmd/utils/argsToBase64.js +25 -0
- package/dist/cmd/utils/argsToBase64.js.map +1 -0
- package/dist/cmd/utils/time.d.ts +77 -0
- package/dist/cmd/utils/time.d.ts.map +1 -0
- package/dist/cmd/utils/time.js +120 -0
- package/dist/cmd/utils/time.js.map +1 -0
- package/dist/connector/Connector.d.ts +2 -0
- package/dist/connector/Connector.d.ts.map +1 -1
- package/dist/connector/Connector.js +13 -9
- package/dist/esm/account/Account.d.ts +103 -0
- package/dist/esm/account/Account.d.ts.map +1 -0
- package/dist/esm/account/Account.js +178 -0
- package/dist/esm/account/Account.js.map +1 -0
- package/dist/esm/account/AccountBalance.d.ts +14 -0
- package/dist/esm/account/AccountBalance.d.ts.map +1 -0
- package/dist/esm/account/AccountBalance.js +2 -0
- package/dist/esm/account/AccountBalance.js.map +1 -0
- package/dist/esm/account/AccountSign.d.ts +16 -0
- package/dist/esm/account/AccountSign.d.ts.map +1 -0
- package/dist/esm/account/AccountSign.js +2 -0
- package/dist/esm/account/AccountSign.js.map +1 -0
- package/dist/esm/account/IAccount.d.ts +20 -0
- package/dist/esm/account/IAccount.d.ts.map +1 -0
- package/dist/esm/account/IAccount.js +2 -0
- package/dist/esm/account/IAccount.js.map +1 -0
- package/dist/esm/account/IAccountCallSCRequest.d.ts +25 -0
- package/dist/esm/account/IAccountCallSCRequest.d.ts.map +1 -0
- package/dist/esm/account/IAccountCallSCRequest.js +2 -0
- package/dist/esm/account/IAccountCallSCRequest.js.map +1 -0
- package/dist/esm/account/IAccountDetails.d.ts +8 -0
- package/dist/esm/account/IAccountDetails.d.ts.map +1 -0
- package/dist/esm/account/IAccountDetails.js +2 -0
- package/dist/esm/account/IAccountDetails.js.map +1 -0
- package/dist/esm/account/IAccountRolls.d.ts +8 -0
- package/dist/esm/account/IAccountRolls.d.ts.map +1 -0
- package/dist/esm/account/IAccountRolls.js +2 -0
- package/dist/esm/account/IAccountRolls.js.map +1 -0
- package/dist/esm/account/IAccountSendTransaction.d.ts +9 -0
- package/dist/esm/account/IAccountSendTransaction.d.ts.map +1 -0
- package/dist/esm/account/IAccountSendTransaction.js +2 -0
- package/dist/esm/account/IAccountSendTransaction.js.map +1 -0
- package/dist/esm/account/index.d.ts +9 -0
- package/dist/esm/account/index.d.ts.map +1 -0
- package/dist/esm/account/index.js +2 -0
- package/dist/esm/account/index.js.map +1 -0
- package/dist/esm/connector/Connector.d.ts +87 -0
- package/dist/esm/connector/Connector.d.ts.map +1 -0
- package/dist/esm/connector/Connector.js +172 -0
- package/dist/esm/connector/Connector.js.map +1 -0
- package/dist/esm/connector/ICustomEventMessageRequest.d.ts +10 -0
- package/dist/esm/connector/ICustomEventMessageRequest.d.ts.map +1 -0
- package/dist/esm/connector/ICustomEventMessageRequest.js +2 -0
- package/dist/esm/connector/ICustomEventMessageRequest.js.map +1 -0
- package/dist/esm/connector/ICustomEventMessageResponse.d.ts +11 -0
- package/dist/esm/connector/ICustomEventMessageResponse.d.ts.map +1 -0
- package/dist/esm/connector/ICustomEventMessageResponse.js +2 -0
- package/dist/esm/connector/ICustomEventMessageResponse.js.map +1 -0
- package/dist/esm/connector/IRegisterEvent.d.ts +8 -0
- package/dist/esm/connector/IRegisterEvent.d.ts.map +1 -0
- package/dist/esm/connector/IRegisterEvent.js +2 -0
- package/dist/esm/connector/IRegisterEvent.js.map +1 -0
- package/dist/esm/connector/index.d.ts +5 -0
- package/dist/esm/connector/index.d.ts.map +1 -0
- package/dist/esm/connector/index.js +2 -0
- package/dist/esm/connector/index.js.map +1 -0
- package/dist/esm/index.d.ts +48 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +79 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/massaStation/MassaStationAccount.d.ts +103 -0
- package/dist/esm/massaStation/MassaStationAccount.d.ts.map +1 -0
- package/dist/esm/massaStation/MassaStationAccount.js +311 -0
- package/dist/esm/massaStation/MassaStationAccount.js.map +1 -0
- package/dist/esm/massaStation/MassaStationDiscovery.d.ts +57 -0
- package/dist/esm/massaStation/MassaStationDiscovery.d.ts.map +1 -0
- package/dist/esm/massaStation/MassaStationDiscovery.js +76 -0
- package/dist/esm/massaStation/MassaStationDiscovery.js.map +1 -0
- package/dist/esm/massaStation/MassaStationProvider.d.ts +91 -0
- package/dist/esm/massaStation/MassaStationProvider.d.ts.map +1 -0
- package/dist/esm/massaStation/MassaStationProvider.js +190 -0
- package/dist/esm/massaStation/MassaStationProvider.js.map +1 -0
- package/dist/esm/massaStation/RequestHandler.d.ts +47 -0
- package/dist/esm/massaStation/RequestHandler.d.ts.map +1 -0
- package/dist/esm/massaStation/RequestHandler.js +126 -0
- package/dist/esm/massaStation/RequestHandler.js.map +1 -0
- package/dist/esm/provider/AccountDeletion.d.ts +24 -0
- package/dist/esm/provider/AccountDeletion.d.ts.map +1 -0
- package/dist/esm/provider/AccountDeletion.js +11 -0
- package/dist/esm/provider/AccountDeletion.js.map +1 -0
- package/dist/esm/provider/AccountImport.d.ts +26 -0
- package/dist/esm/provider/AccountImport.d.ts.map +1 -0
- package/dist/esm/provider/AccountImport.js +11 -0
- package/dist/esm/provider/AccountImport.js.map +1 -0
- package/dist/esm/provider/AccoutGeneration.d.ts +8 -0
- package/dist/esm/provider/AccoutGeneration.d.ts.map +1 -0
- package/dist/esm/provider/AccoutGeneration.js +2 -0
- package/dist/esm/provider/AccoutGeneration.js.map +1 -0
- package/dist/esm/provider/IProvider.d.ts +16 -0
- package/dist/esm/provider/IProvider.d.ts.map +1 -0
- package/dist/esm/provider/IProvider.js +2 -0
- package/dist/esm/provider/IProvider.js.map +1 -0
- package/dist/esm/provider/Provider.d.ts +68 -0
- package/dist/esm/provider/Provider.d.ts.map +1 -0
- package/dist/esm/provider/Provider.js +123 -0
- package/dist/esm/provider/Provider.js.map +1 -0
- package/dist/esm/provider/index.d.ts +5 -0
- package/dist/esm/provider/index.d.ts.map +1 -0
- package/dist/esm/provider/index.js +4 -0
- package/dist/esm/provider/index.js.map +1 -0
- package/dist/esm/utils/argsToBase64.d.ts +16 -0
- package/dist/esm/utils/argsToBase64.d.ts.map +1 -0
- package/dist/esm/utils/argsToBase64.js +20 -0
- package/dist/esm/utils/argsToBase64.js.map +1 -0
- package/dist/esm/utils/time.d.ts +77 -0
- package/dist/esm/utils/time.d.ts.map +1 -0
- package/dist/esm/utils/time.js +119 -0
- package/dist/esm/utils/time.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/massaStation/MassaStationDiscovery.d.ts +2 -16
- package/dist/massaStation/MassaStationDiscovery.d.ts.map +1 -1
- package/dist/massaStation/MassaStationDiscovery.js +4 -30
- package/package.json +11 -8
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Args } from '@massalabs/web3-utils';
|
|
2
|
+
/**
|
|
3
|
+
* This interface represents the request object to send to the content script to
|
|
4
|
+
* interact with a deployed smart contract.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* - If your smart contract function does not require any parameters, you can pass an empty array.
|
|
8
|
+
*
|
|
9
|
+
* @see nickname - The nickname of the account to use.
|
|
10
|
+
* @see name - The name of the function to be called.
|
|
11
|
+
* @see at - The address of the smart contract.
|
|
12
|
+
* @see args - The parameters as an Args object to be passed to the function.
|
|
13
|
+
* @see coins - The amount of MASSA coins to be sent to the block creator.
|
|
14
|
+
* @see dryRun - The parameters for the dry run.
|
|
15
|
+
*/
|
|
16
|
+
export interface IAccountCallSCRequest {
|
|
17
|
+
nickname: string;
|
|
18
|
+
name: string;
|
|
19
|
+
at: string;
|
|
20
|
+
args: Args;
|
|
21
|
+
coins: bigint;
|
|
22
|
+
fee: bigint;
|
|
23
|
+
nonPersistentExecution: boolean;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=IAccountCallSCRequest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IAccountCallSCRequest.d.ts","sourceRoot":"","sources":["../../../src/account/IAccountCallSCRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAE7C;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,sBAAsB,EAAE,OAAO,CAAC;CACjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IAccountCallSCRequest.js","sourceRoot":"","sources":["../../../src/account/IAccountCallSCRequest.ts"],"names":[],"mappings":"","sourcesContent":["import { Args } from '@massalabs/web3-utils';\n\n/**\n * This interface represents the request object to send to the content script to\n * interact with a deployed smart contract.\n *\n * @remarks\n * - If your smart contract function does not require any parameters, you can pass an empty array.\n *\n * @see nickname - The nickname of the account to use.\n * @see name - The name of the function to be called.\n * @see at - The address of the smart contract.\n * @see args - The parameters as an Args object to be passed to the function.\n * @see coins - The amount of MASSA coins to be sent to the block creator.\n * @see dryRun - The parameters for the dry run.\n */\nexport interface IAccountCallSCRequest {\n nickname: string;\n name: string;\n at: string;\n args: Args;\n coins: bigint;\n fee: bigint;\n nonPersistentExecution: boolean;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IAccountDetails.d.ts","sourceRoot":"","sources":["../../../src/account/IAccountDetails.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IAccountDetails.js","sourceRoot":"","sources":["../../../src/account/IAccountDetails.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * This interface represents the account details such as name and address.\n */\nexport interface IAccountDetails {\n name?: string;\n address: string;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IAccountRolls.d.ts","sourceRoot":"","sources":["../../../src/account/IAccountRolls.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IAccountRolls.js","sourceRoot":"","sources":["../../../src/account/IAccountRolls.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * This interface represents the request object for roll operations (buy & sell) sent to the content script.\n */\nexport interface IAccountRollsRequest {\n amount: string;\n fee: string;\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This interface represents the request object for roll operations (buy & sell) sent to the content script.
|
|
3
|
+
*/
|
|
4
|
+
export interface IAccountSendTransactionRequest {
|
|
5
|
+
recipientAddress: string;
|
|
6
|
+
amount: string;
|
|
7
|
+
fee: string;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=IAccountSendTransaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IAccountSendTransaction.d.ts","sourceRoot":"","sources":["../../../src/account/IAccountSendTransaction.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IAccountSendTransaction.js","sourceRoot":"","sources":["../../../src/account/IAccountSendTransaction.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * This interface represents the request object for roll operations (buy & sell) sent to the content script.\n */\nexport interface IAccountSendTransactionRequest {\n recipientAddress: string;\n amount: string;\n fee: string;\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { Account } from './Account';
|
|
2
|
+
export { IAccountBalanceRequest, IAccountBalanceResponse, } from './AccountBalance';
|
|
3
|
+
export { IAccount } from './IAccount';
|
|
4
|
+
export { IAccountSignRequest, IAccountSignResponse } from './AccountSign';
|
|
5
|
+
export { IAccountDetails } from './IAccountDetails';
|
|
6
|
+
export { IAccountRollsRequest } from './IAccountRolls';
|
|
7
|
+
export { IAccountSendTransactionRequest } from './IAccountSendTransaction';
|
|
8
|
+
export { IAccountCallSCRequest } from './IAccountCallSCRequest';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/account/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,8BAA8B,EAAE,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Account = void 0;
|
|
4
|
+
var Account_1 = require("./Account");
|
|
5
|
+
Object.defineProperty(exports, "Account", { enumerable: true, get: function () { return Account_1.Account; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/account/index.ts"],"names":[],"mappings":";;;AAAA,qCAAoC;AAA3B,kGAAA,OAAO,OAAA","sourcesContent":["export { Account } from './Account';\nexport {\n IAccountBalanceRequest,\n IAccountBalanceResponse,\n} from './AccountBalance';\nexport { IAccount } from './IAccount';\nexport { IAccountSignRequest, IAccountSignResponse } from './AccountSign';\nexport { IAccountDetails } from './IAccountDetails';\nexport { IAccountRollsRequest } from './IAccountRolls';\nexport { IAccountSendTransactionRequest } from './IAccountSendTransaction';\nexport { IAccountCallSCRequest } from './IAccountCallSCRequest';\n"]}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { AvailableCommands, IAccountBalanceRequest, IAccountBalanceResponse, IAccountDeletionRequest, IAccountDeletionResponse, IAccountImportRequest, IAccountImportResponse, IAccountSignRequest, IAccountSignResponse } from '..';
|
|
2
|
+
import { IAccount } from '../account/IAccount';
|
|
3
|
+
/**
|
|
4
|
+
* A constant string that is used to identify the HTML element that is used for
|
|
5
|
+
* communication between the web page script and the content script.
|
|
6
|
+
*/
|
|
7
|
+
export declare const MASSA_WINDOW_OBJECT = "massaWalletProvider";
|
|
8
|
+
type CallbackFunction = (result: AllowedResponses, error: Error | null) => unknown;
|
|
9
|
+
export type AllowedRequests = object | IAccountBalanceRequest | IAccountSignRequest | IAccountImportRequest | IAccountDeletionRequest;
|
|
10
|
+
export type AllowedResponses = object | IAccountBalanceResponse | IAccountSignResponse | IAccountImportResponse | IAccountDeletionResponse | IAccount[] | string;
|
|
11
|
+
/**
|
|
12
|
+
* This class enables communication with the content script by sending and receiving messages.
|
|
13
|
+
* @remarks
|
|
14
|
+
* - This class is used to send messages to the content script and to receive messages from the content script.
|
|
15
|
+
* - It is used to send messages to the content script and to receive messages from the content script.
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
declare class Connector {
|
|
19
|
+
private registeredProviders;
|
|
20
|
+
private pendingRequests;
|
|
21
|
+
private massaStationListener;
|
|
22
|
+
/**
|
|
23
|
+
* Connector constructor
|
|
24
|
+
*
|
|
25
|
+
* @remarks
|
|
26
|
+
* - The Connector constructor takes no arguments.
|
|
27
|
+
* - It creates a Map object that is used to store pending requests.
|
|
28
|
+
* - It creates an HTML element that is used to communicate with the content script.
|
|
29
|
+
* - It adds an event listener to the HTML element that is used to communicate with the content script.
|
|
30
|
+
*
|
|
31
|
+
* @returns An instance of the Connector class.
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
34
|
+
constructor();
|
|
35
|
+
/**
|
|
36
|
+
* This method adds a register listener in the web page.
|
|
37
|
+
* It listens to the 'register' event.
|
|
38
|
+
*
|
|
39
|
+
* @returns void
|
|
40
|
+
*
|
|
41
|
+
* @remarks
|
|
42
|
+
* - It is used to register a new provider.
|
|
43
|
+
* - This method creates a new HTML element and a listener that listens to the register event.
|
|
44
|
+
*
|
|
45
|
+
*/
|
|
46
|
+
private register;
|
|
47
|
+
private initMassaStationListener;
|
|
48
|
+
startMassaStationDiscovery(): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* This method sends a message from the webpage script to the content script.
|
|
51
|
+
*
|
|
52
|
+
* @remarks
|
|
53
|
+
* Sends a message to the content script using the specified provider name, command, and parameters,
|
|
54
|
+
*
|
|
55
|
+
* @privateRemarks
|
|
56
|
+
* This method registers the response callback with a unique ID.
|
|
57
|
+
*
|
|
58
|
+
* @param providerName - The name of the provider.
|
|
59
|
+
* @param command - The command that is sent to the content script (among the {@link AvailableCommands}).
|
|
60
|
+
* @param params - The parameters that are sent to the content script.
|
|
61
|
+
* @param responseCallback - The callback function that is called when the content script sends a response.
|
|
62
|
+
* @returns void
|
|
63
|
+
*
|
|
64
|
+
*/
|
|
65
|
+
sendMessageToContentScript(providerName: string, command: AvailableCommands, params: AllowedRequests, responseCallback: CallbackFunction): void;
|
|
66
|
+
/**
|
|
67
|
+
* This method returns the registered providers.
|
|
68
|
+
*
|
|
69
|
+
* @returns The registered provider associated with its unique key.
|
|
70
|
+
*
|
|
71
|
+
*/
|
|
72
|
+
getWalletProviders(): {
|
|
73
|
+
[key: string]: string;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* This method handles the response from the content script by
|
|
77
|
+
* calling the response callback with the response and error objects.
|
|
78
|
+
*
|
|
79
|
+
* @param event - The event that is sent from the content script.
|
|
80
|
+
* @returns void
|
|
81
|
+
*
|
|
82
|
+
*/
|
|
83
|
+
private handleResponseFromContentScript;
|
|
84
|
+
}
|
|
85
|
+
export declare const connector: Connector;
|
|
86
|
+
export {};
|
|
87
|
+
//# sourceMappingURL=Connector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Connector.d.ts","sourceRoot":"","sources":["../../../src/connector/Connector.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,IAAI,CAAC;AAOZ,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C;;;GAGG;AACH,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAEzD,KAAK,gBAAgB,GAAG,CACtB,MAAM,EAAE,gBAAgB,EACxB,KAAK,EAAE,KAAK,GAAG,IAAI,KAChB,OAAO,CAAC;AAEb,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,sBAAsB,GACtB,mBAAmB,GACnB,qBAAqB,GACrB,uBAAuB,CAAC;AAE5B,MAAM,MAAM,gBAAgB,GACxB,MAAM,GACN,uBAAuB,GACvB,oBAAoB,GACpB,sBAAsB,GACtB,wBAAwB,GACxB,QAAQ,EAAE,GACV,MAAM,CAAC;AAEX;;;;;;GAMG;AACH,cAAM,SAAS;IACb,OAAO,CAAC,mBAAmB,CAAiC;IAC5D,OAAO,CAAC,eAAe,CAAgC;IACvD,OAAO,CAAC,oBAAoB,CAAwB;IAEpD;;;;;;;;;;;OAWG;;IAgBH;;;;;;;;;;OAUG;IACH,OAAO,CAAC,QAAQ;IAqBhB,OAAO,CAAC,wBAAwB;IAWnB,0BAA0B;IAQvC;;;;;;;;;;;;;;;OAeG;IAEI,0BAA0B,CAC/B,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,eAAe,EACvB,gBAAgB,EAAE,gBAAgB;IAgCpC;;;;;OAKG;IACI,kBAAkB,IAAI;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE;IAItD;;;;;;;OAOG;IACH,OAAO,CAAC,+BAA+B;CAuBxC;AAED,eAAO,MAAM,SAAS,WAAkB,CAAC"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.connector = exports.MASSA_WINDOW_OBJECT = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* This file defines a TypeScript module named connector.
|
|
6
|
+
* It is the tool that allows the 'provider' and 'account' objects to communicate with the web page script.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* - If you are only looking to use our library, the connector object will not be useful to you.
|
|
10
|
+
* - If you want to work on this repo, you will probably be interested in this object
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
const uid_1 = require("uid");
|
|
14
|
+
const __1 = require("..");
|
|
15
|
+
const MassaStationDiscovery_1 = require("../massaStation/MassaStationDiscovery");
|
|
16
|
+
const MassaStationProvider_1 = require("../massaStation/MassaStationProvider");
|
|
17
|
+
/**
|
|
18
|
+
* A constant string that is used to identify the HTML element that is used for
|
|
19
|
+
* communication between the web page script and the content script.
|
|
20
|
+
*/
|
|
21
|
+
exports.MASSA_WINDOW_OBJECT = 'massaWalletProvider';
|
|
22
|
+
/**
|
|
23
|
+
* This class enables communication with the content script by sending and receiving messages.
|
|
24
|
+
* @remarks
|
|
25
|
+
* - This class is used to send messages to the content script and to receive messages from the content script.
|
|
26
|
+
* - It is used to send messages to the content script and to receive messages from the content script.
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
class Connector {
|
|
30
|
+
/**
|
|
31
|
+
* Connector constructor
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* - The Connector constructor takes no arguments.
|
|
35
|
+
* - It creates a Map object that is used to store pending requests.
|
|
36
|
+
* - It creates an HTML element that is used to communicate with the content script.
|
|
37
|
+
* - It adds an event listener to the HTML element that is used to communicate with the content script.
|
|
38
|
+
*
|
|
39
|
+
* @returns An instance of the Connector class.
|
|
40
|
+
*
|
|
41
|
+
*/
|
|
42
|
+
constructor() {
|
|
43
|
+
this.registeredProviders = {};
|
|
44
|
+
this.pendingRequests = new Map();
|
|
45
|
+
this.massaStationListener = new MassaStationDiscovery_1.MassaStationDiscovery();
|
|
46
|
+
this.initMassaStationListener();
|
|
47
|
+
this.register();
|
|
48
|
+
// start listening to messages from content script
|
|
49
|
+
document
|
|
50
|
+
.getElementById(exports.MASSA_WINDOW_OBJECT)
|
|
51
|
+
.addEventListener('message', this.handleResponseFromContentScript.bind(this));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* This method adds a register listener in the web page.
|
|
55
|
+
* It listens to the 'register' event.
|
|
56
|
+
*
|
|
57
|
+
* @returns void
|
|
58
|
+
*
|
|
59
|
+
* @remarks
|
|
60
|
+
* - It is used to register a new provider.
|
|
61
|
+
* - This method creates a new HTML element and a listener that listens to the register event.
|
|
62
|
+
*
|
|
63
|
+
*/
|
|
64
|
+
register() {
|
|
65
|
+
// global event target to use for all wallet provider
|
|
66
|
+
if (!document.getElementById(exports.MASSA_WINDOW_OBJECT)) {
|
|
67
|
+
const inv = document.createElement('p');
|
|
68
|
+
inv.id = exports.MASSA_WINDOW_OBJECT;
|
|
69
|
+
inv.setAttribute('style', 'display:none');
|
|
70
|
+
document.body.appendChild(inv);
|
|
71
|
+
}
|
|
72
|
+
// add an invisible HTML element and set a listener to it like the following
|
|
73
|
+
// hook up register handler
|
|
74
|
+
document
|
|
75
|
+
.getElementById(exports.MASSA_WINDOW_OBJECT)
|
|
76
|
+
.addEventListener('register', (evt) => {
|
|
77
|
+
const payload = evt.detail;
|
|
78
|
+
const providerEventTargetName = `${exports.MASSA_WINDOW_OBJECT}_${payload.providerName}`;
|
|
79
|
+
this.registeredProviders[payload.providerName] =
|
|
80
|
+
providerEventTargetName;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
initMassaStationListener() {
|
|
84
|
+
this.massaStationListener.on(MassaStationDiscovery_1.ON_MASSA_STATION_DISCOVERED, () => {
|
|
85
|
+
this.registeredProviders[MassaStationProvider_1.MASSA_STATION_PROVIDER_NAME] = `${exports.MASSA_WINDOW_OBJECT}_${MassaStationProvider_1.MASSA_STATION_PROVIDER_NAME}`;
|
|
86
|
+
});
|
|
87
|
+
this.massaStationListener.on(MassaStationDiscovery_1.ON_MASSA_STATION_DISCONNECTED, () => {
|
|
88
|
+
delete this.registeredProviders[MassaStationProvider_1.MASSA_STATION_PROVIDER_NAME];
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
async startMassaStationDiscovery() {
|
|
92
|
+
try {
|
|
93
|
+
await this.massaStationListener.startListening();
|
|
94
|
+
}
|
|
95
|
+
catch (e) {
|
|
96
|
+
console.log('MassaStation is not detected');
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* This method sends a message from the webpage script to the content script.
|
|
101
|
+
*
|
|
102
|
+
* @remarks
|
|
103
|
+
* Sends a message to the content script using the specified provider name, command, and parameters,
|
|
104
|
+
*
|
|
105
|
+
* @privateRemarks
|
|
106
|
+
* This method registers the response callback with a unique ID.
|
|
107
|
+
*
|
|
108
|
+
* @param providerName - The name of the provider.
|
|
109
|
+
* @param command - The command that is sent to the content script (among the {@link AvailableCommands}).
|
|
110
|
+
* @param params - The parameters that are sent to the content script.
|
|
111
|
+
* @param responseCallback - The callback function that is called when the content script sends a response.
|
|
112
|
+
* @returns void
|
|
113
|
+
*
|
|
114
|
+
*/
|
|
115
|
+
sendMessageToContentScript(providerName, command, params, responseCallback) {
|
|
116
|
+
if (!Object.values(__1.AvailableCommands).includes(command)) {
|
|
117
|
+
throw new Error(`Unknown command ${command}`);
|
|
118
|
+
}
|
|
119
|
+
const requestId = (0, uid_1.uid)();
|
|
120
|
+
const eventMessageRequest = {
|
|
121
|
+
params,
|
|
122
|
+
requestId,
|
|
123
|
+
};
|
|
124
|
+
this.pendingRequests.set(requestId, responseCallback);
|
|
125
|
+
// dispatch an event to the specific provider event target
|
|
126
|
+
const specificProviderEventTarget = document.getElementById(`${this.registeredProviders[providerName]}`);
|
|
127
|
+
if (!specificProviderEventTarget) {
|
|
128
|
+
throw new Error(`Registered provider with name ${providerName} does not exist`);
|
|
129
|
+
}
|
|
130
|
+
const isDispatched = specificProviderEventTarget.dispatchEvent(new CustomEvent(command, { detail: eventMessageRequest }));
|
|
131
|
+
if (!isDispatched) {
|
|
132
|
+
throw new Error(`Could not dispatch a message to ${this.registeredProviders[providerName]}`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* This method returns the registered providers.
|
|
137
|
+
*
|
|
138
|
+
* @returns The registered provider associated with its unique key.
|
|
139
|
+
*
|
|
140
|
+
*/
|
|
141
|
+
getWalletProviders() {
|
|
142
|
+
return this.registeredProviders;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* This method handles the response from the content script by
|
|
146
|
+
* calling the response callback with the response and error objects.
|
|
147
|
+
*
|
|
148
|
+
* @param event - The event that is sent from the content script.
|
|
149
|
+
* @returns void
|
|
150
|
+
*
|
|
151
|
+
*/
|
|
152
|
+
handleResponseFromContentScript(event) {
|
|
153
|
+
const { result, error, requestId } = event.detail;
|
|
154
|
+
const responseCallback = this.pendingRequests.get(requestId);
|
|
155
|
+
if (responseCallback) {
|
|
156
|
+
if (error) {
|
|
157
|
+
responseCallback(null, new Error(error.message));
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
responseCallback(result, null);
|
|
161
|
+
}
|
|
162
|
+
const deleted = this.pendingRequests.delete(requestId);
|
|
163
|
+
if (!deleted) {
|
|
164
|
+
console.error(`Error deleting a pending request with id ${requestId}`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
console.error(`Request Id ${requestId} not found in response callback map`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
exports.connector = new Connector();
|
|
173
|
+
//# sourceMappingURL=Connector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Connector.js","sourceRoot":"","sources":["../../../src/connector/Connector.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * This file defines a TypeScript module named connector.\n * It is the tool that allows the 'provider' and 'account' objects to communicate with the web page script.\n *\n * @remarks\n * - If you are only looking to use our library, the connector object will not be useful to you.\n * - If you want to work on this repo, you will probably be interested in this object\n *\n */\nimport { uid } from 'uid';\nimport { ICustomEventMessageResponse } from './ICustomEventMessageResponse';\nimport { ICustomEventMessageRequest } from './ICustomEventMessageRequest';\nimport { IRegisterEvent } from './IRegisterEvent';\nimport {\n AvailableCommands,\n IAccountBalanceRequest,\n IAccountBalanceResponse,\n IAccountDeletionRequest,\n IAccountDeletionResponse,\n IAccountImportRequest,\n IAccountImportResponse,\n IAccountSignRequest,\n IAccountSignResponse,\n} from '..';\nimport {\n ON_MASSA_STATION_DISCOVERED,\n ON_MASSA_STATION_DISCONNECTED,\n MassaStationDiscovery,\n} from '../massaStation/MassaStationDiscovery';\nimport { MASSA_STATION_PROVIDER_NAME } from '../massaStation/MassaStationProvider';\nimport { IAccount } from '../account/IAccount';\n\n/**\n * A constant string that is used to identify the HTML element that is used for\n * communication between the web page script and the content script.\n */\nexport const MASSA_WINDOW_OBJECT = 'massaWalletProvider';\n\ntype CallbackFunction = (\n result: AllowedResponses,\n error: Error | null,\n) => unknown;\n\nexport type AllowedRequests =\n | object\n | IAccountBalanceRequest\n | IAccountSignRequest\n | IAccountImportRequest\n | IAccountDeletionRequest;\n\nexport type AllowedResponses =\n | object\n | IAccountBalanceResponse\n | IAccountSignResponse\n | IAccountImportResponse\n | IAccountDeletionResponse\n | IAccount[]\n | string;\n\n/**\n * This class enables communication with the content script by sending and receiving messages.\n * @remarks\n * - This class is used to send messages to the content script and to receive messages from the content script.\n * - It is used to send messages to the content script and to receive messages from the content script.\n *\n */\nclass Connector {\n private registeredProviders: { [key: string]: string } = {};\n private pendingRequests: Map<string, CallbackFunction>;\n private massaStationListener: MassaStationDiscovery;\n\n /**\n * Connector constructor\n *\n * @remarks\n * - The Connector constructor takes no arguments.\n * - It creates a Map object that is used to store pending requests.\n * - It creates an HTML element that is used to communicate with the content script.\n * - It adds an event listener to the HTML element that is used to communicate with the content script.\n *\n * @returns An instance of the Connector class.\n *\n */\n public constructor() {\n this.pendingRequests = new Map<string, CallbackFunction>();\n this.massaStationListener = new MassaStationDiscovery();\n this.initMassaStationListener();\n this.register();\n\n // start listening to messages from content script\n document\n .getElementById(MASSA_WINDOW_OBJECT)\n .addEventListener(\n 'message',\n this.handleResponseFromContentScript.bind(this),\n );\n }\n\n /**\n * This method adds a register listener in the web page.\n * It listens to the 'register' event.\n *\n * @returns void\n *\n * @remarks\n * - It is used to register a new provider.\n * - This method creates a new HTML element and a listener that listens to the register event.\n *\n */\n private register() {\n // global event target to use for all wallet provider\n if (!document.getElementById(MASSA_WINDOW_OBJECT)) {\n const inv = document.createElement('p');\n inv.id = MASSA_WINDOW_OBJECT;\n inv.setAttribute('style', 'display:none');\n document.body.appendChild(inv);\n }\n\n // add an invisible HTML element and set a listener to it like the following\n // hook up register handler\n document\n .getElementById(MASSA_WINDOW_OBJECT)\n .addEventListener('register', (evt: CustomEvent) => {\n const payload: IRegisterEvent = evt.detail;\n const providerEventTargetName = `${MASSA_WINDOW_OBJECT}_${payload.providerName}`;\n this.registeredProviders[payload.providerName] =\n providerEventTargetName;\n });\n }\n\n private initMassaStationListener() {\n this.massaStationListener.on(ON_MASSA_STATION_DISCOVERED, () => {\n this.registeredProviders[\n MASSA_STATION_PROVIDER_NAME\n ] = `${MASSA_WINDOW_OBJECT}_${MASSA_STATION_PROVIDER_NAME}`;\n });\n this.massaStationListener.on(ON_MASSA_STATION_DISCONNECTED, () => {\n delete this.registeredProviders[MASSA_STATION_PROVIDER_NAME];\n });\n }\n\n public async startMassaStationDiscovery() {\n try {\n await this.massaStationListener.startListening();\n } catch (e) {\n console.log('MassaStation is not detected');\n }\n }\n\n /**\n * This method sends a message from the webpage script to the content script.\n *\n * @remarks\n * Sends a message to the content script using the specified provider name, command, and parameters,\n *\n * @privateRemarks\n * This method registers the response callback with a unique ID.\n *\n * @param providerName - The name of the provider.\n * @param command - The command that is sent to the content script (among the {@link AvailableCommands}).\n * @param params - The parameters that are sent to the content script.\n * @param responseCallback - The callback function that is called when the content script sends a response.\n * @returns void\n *\n */\n\n public sendMessageToContentScript(\n providerName: string,\n command: AvailableCommands,\n params: AllowedRequests,\n responseCallback: CallbackFunction,\n ) {\n if (!Object.values(AvailableCommands).includes(command)) {\n throw new Error(`Unknown command ${command}`);\n }\n\n const requestId = uid();\n const eventMessageRequest: ICustomEventMessageRequest = {\n params,\n requestId,\n };\n this.pendingRequests.set(requestId, responseCallback);\n\n // dispatch an event to the specific provider event target\n const specificProviderEventTarget = document.getElementById(\n `${this.registeredProviders[providerName]}`,\n ) as EventTarget;\n if (!specificProviderEventTarget) {\n throw new Error(\n `Registered provider with name ${providerName} does not exist`,\n );\n }\n const isDispatched = specificProviderEventTarget.dispatchEvent(\n new CustomEvent(command, { detail: eventMessageRequest }),\n );\n if (!isDispatched) {\n throw new Error(\n `Could not dispatch a message to ${this.registeredProviders[providerName]}`,\n );\n }\n }\n\n /**\n * This method returns the registered providers.\n *\n * @returns The registered provider associated with its unique key.\n *\n */\n public getWalletProviders(): { [key: string]: string } {\n return this.registeredProviders;\n }\n\n /**\n * This method handles the response from the content script by\n * calling the response callback with the response and error objects.\n *\n * @param event - The event that is sent from the content script.\n * @returns void\n *\n */\n private handleResponseFromContentScript(event: CustomEvent) {\n const { result, error, requestId }: ICustomEventMessageResponse =\n event.detail;\n\n const responseCallback: CallbackFunction =\n this.pendingRequests.get(requestId);\n\n if (responseCallback) {\n if (error) {\n responseCallback(null, new Error(error.message));\n } else {\n responseCallback(result, null);\n }\n const deleted = this.pendingRequests.delete(requestId);\n if (!deleted) {\n console.error(`Error deleting a pending request with id ${requestId}`);\n }\n } else {\n console.error(\n `Request Id ${requestId} not found in response callback map`,\n );\n }\n }\n}\n\nexport const connector = new Connector();\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AllowedRequests } from './Connector';
|
|
2
|
+
/**
|
|
3
|
+
* This interface represents the request done by the web page script to the content script
|
|
4
|
+
* in order to setup a custom event.
|
|
5
|
+
*/
|
|
6
|
+
export interface ICustomEventMessageRequest {
|
|
7
|
+
params: AllowedRequests;
|
|
8
|
+
requestId: string;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=ICustomEventMessageRequest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ICustomEventMessageRequest.d.ts","sourceRoot":"","sources":["../../../src/connector/ICustomEventMessageRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ICustomEventMessageRequest.js","sourceRoot":"","sources":["../../../src/connector/ICustomEventMessageRequest.ts"],"names":[],"mappings":"","sourcesContent":["import { AllowedRequests } from './Connector';\n\n/**\n * This interface represents the request done by the web page script to the content script\n * in order to setup a custom event.\n */\nexport interface ICustomEventMessageRequest {\n params: AllowedRequests;\n requestId: string;\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AllowedResponses } from './Connector';
|
|
2
|
+
/**
|
|
3
|
+
* This interface represents the response from the content script to the web page script
|
|
4
|
+
* for an ICustomEventMessageRequest.
|
|
5
|
+
*/
|
|
6
|
+
export interface ICustomEventMessageResponse {
|
|
7
|
+
result?: AllowedResponses;
|
|
8
|
+
error?: Error;
|
|
9
|
+
requestId: string;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=ICustomEventMessageResponse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ICustomEventMessageResponse.d.ts","sourceRoot":"","sources":["../../../src/connector/ICustomEventMessageResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ICustomEventMessageResponse.js","sourceRoot":"","sources":["../../../src/connector/ICustomEventMessageResponse.ts"],"names":[],"mappings":"","sourcesContent":["import { AllowedResponses } from './Connector';\n\n/**\n * This interface represents the response from the content script to the web page script\n * for an ICustomEventMessageRequest.\n */\nexport interface ICustomEventMessageResponse {\n result?: AllowedResponses;\n error?: Error;\n requestId: string;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IRegisterEvent.d.ts","sourceRoot":"","sources":["../../../src/connector/IRegisterEvent.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IRegisterEvent.js","sourceRoot":"","sources":["../../../src/connector/IRegisterEvent.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * This interface represents the object that is used to register an event.\n */\nexport interface IRegisterEvent {\n providerName: string;\n eventTarget: string;\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { connector, AllowedRequests, AllowedResponses, MASSA_WINDOW_OBJECT, } from './Connector';
|
|
2
|
+
export { ICustomEventMessageRequest } from './ICustomEventMessageRequest';
|
|
3
|
+
export { ICustomEventMessageResponse } from './ICustomEventMessageResponse';
|
|
4
|
+
export { IRegisterEvent } from './IRegisterEvent';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connector/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MASSA_WINDOW_OBJECT = exports.connector = void 0;
|
|
4
|
+
var Connector_1 = require("./Connector");
|
|
5
|
+
Object.defineProperty(exports, "connector", { enumerable: true, get: function () { return Connector_1.connector; } });
|
|
6
|
+
Object.defineProperty(exports, "MASSA_WINDOW_OBJECT", { enumerable: true, get: function () { return Connector_1.MASSA_WINDOW_OBJECT; } });
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connector/index.ts"],"names":[],"mappings":";;;AAAA,yCAKqB;AAJnB,sGAAA,SAAS,OAAA;AAGT,gHAAA,mBAAmB,OAAA","sourcesContent":["export {\n connector,\n AllowedRequests,\n AllowedResponses,\n MASSA_WINDOW_OBJECT,\n} from './Connector';\nexport { ICustomEventMessageRequest } from './ICustomEventMessageRequest';\nexport { ICustomEventMessageResponse } from './ICustomEventMessageResponse';\nexport { IRegisterEvent } from './IRegisterEvent';\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/** Polyfills */
|
|
3
|
+
import { Buffer } from 'buffer';
|
|
4
|
+
declare global {
|
|
5
|
+
interface Window {
|
|
6
|
+
Buffer: typeof Buffer;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
import { IProvider } from './provider/IProvider';
|
|
10
|
+
export declare enum AvailableCommands {
|
|
11
|
+
ProviderListAccounts = "LIST_ACCOUNTS",
|
|
12
|
+
ProviderDeleteAccount = "DELETE_ACCOUNT",
|
|
13
|
+
ProviderImportAccount = "IMPORT_ACCOUNT",
|
|
14
|
+
ProviderGetNodesUrls = "GET_NODES_URLS",
|
|
15
|
+
AccountBalance = "ACCOUNT_BALANCE",
|
|
16
|
+
AccountSign = "ACCOUNT_SIGN",
|
|
17
|
+
ProviderGenerateNewAccount = "GENERATE_NEW_ACCOUNT",
|
|
18
|
+
AccountSellRolls = "ACCOUNT_SELL_ROLLS",
|
|
19
|
+
AccountBuyRolls = "ACCOUNT_BUY_ROLLS",
|
|
20
|
+
AccountSendTransaction = "ACCOUNT_SEND_TRANSACTION",
|
|
21
|
+
AccountCallSC = "ACCOUNT_CALL_SC"
|
|
22
|
+
}
|
|
23
|
+
export interface ITransactionDetails {
|
|
24
|
+
operationId: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get the list of providers that are available to interact with.
|
|
28
|
+
*
|
|
29
|
+
* @param retry - If true, will retry to get the list of providers if none are available.
|
|
30
|
+
* @param pollInterval - The timeout in milliseconds to wait between retries. default is 2000ms.
|
|
31
|
+
* @param timeout - The timeout in milliseconds to wait before giving up. default is 3000ms.
|
|
32
|
+
*
|
|
33
|
+
* @returns An array of providers.
|
|
34
|
+
*/
|
|
35
|
+
export declare function providers(retry?: boolean, timeout?: number, pollInterval?: number): Promise<IProvider[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Manually register a provider to interact with.
|
|
38
|
+
*
|
|
39
|
+
* @param name - The name of the provider.
|
|
40
|
+
* @param id - The id of the HTML element that is used to communicate with the provider.
|
|
41
|
+
*/
|
|
42
|
+
export declare function registerProvider(name: string, id?: string): void;
|
|
43
|
+
export { AllowedRequests, AllowedResponses } from './connector';
|
|
44
|
+
export { IAccountDetails, IAccountBalanceRequest, IAccountBalanceResponse, IAccountSignRequest, IAccountSignResponse, IAccount, Account, IAccountRollsRequest, IAccountSendTransactionRequest, IAccountCallSCRequest, } from './account';
|
|
45
|
+
export { EAccountDeletionResponse, EAccountImportResponse, IAccountDeletionRequest, IAccountDeletionResponse, IAccountImportRequest, IAccountImportResponse, IProvider, Provider, } from './provider';
|
|
46
|
+
export { IMassaStationWallet } from './massaStation/MassaStationProvider';
|
|
47
|
+
export { MassaStationAccount } from './massaStation/MassaStationAccount';
|
|
48
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,gBAAgB;AAChB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,MAAM,EAAE,OAAO,MAAM,CAAC;KACvB;CACF;AAQD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAOjD,oBAAY,iBAAiB;IAC3B,oBAAoB,kBAAkB;IACtC,qBAAqB,mBAAmB;IACxC,qBAAqB,mBAAmB;IACxC,oBAAoB,mBAAmB;IACvC,cAAc,oBAAoB;IAClC,WAAW,iBAAiB;IAC5B,0BAA0B,yBAAyB;IACnD,gBAAgB,uBAAuB;IACvC,eAAe,sBAAsB;IACrC,sBAAsB,6BAA6B;IACnD,aAAa,oBAAoB;CAClC;AAED,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,wBAAsB,SAAS,CAC7B,KAAK,UAAO,EACZ,OAAO,SAAO,EACd,YAAY,SAAM,GACjB,OAAO,CAAC,SAAS,EAAE,CAAC,CA6BtB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,SAAsB,GAAG,IAAI,CAQ7E;AAED,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEhE,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,QAAQ,EACR,OAAO,EACP,oBAAoB,EACpB,8BAA8B,EAC9B,qBAAqB,GACtB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,SAAS,EACT,QAAQ,GACT,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAE1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC"}
|