@prosopo/procaptcha 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/api/AccountCreator.js +1 -1
- package/dist/api/AccountCreator.js.map +1 -1
- package/dist/api/ExtensionWeb2.js +2 -2
- package/dist/api/ExtensionWeb2.js.map +1 -1
- package/dist/api/ExtensionWeb3.d.ts +34 -2
- package/dist/api/ExtensionWeb3.d.ts.map +1 -1
- package/dist/api/ExtensionWeb3.js +52 -10
- package/dist/api/ExtensionWeb3.js.map +1 -1
- package/package.json +9 -8
- package/dist/api/AsyncFactory.d.ts +0 -7
- package/dist/api/AsyncFactory.d.ts.map +0 -1
- package/dist/api/AsyncFactory.js +0 -30
- package/dist/api/AsyncFactory.js.map +0 -1
- package/dist/api/HttpClientBase.d.ts +0 -9
- package/dist/api/HttpClientBase.d.ts.map +0 -1
- package/dist/api/HttpClientBase.js +0 -36
- package/dist/api/HttpClientBase.js.map +0 -1
- package/dist/api/ProsopoContract.d.ts +0 -13
- package/dist/api/ProsopoContract.d.ts.map +0 -1
- package/dist/api/ProsopoContract.js +0 -38
- package/dist/api/ProsopoContract.js.map +0 -1
- package/dist/api/ProsopoContractBase.d.ts +0 -32
- package/dist/api/ProsopoContractBase.d.ts.map +0 -1
- package/dist/api/ProsopoContractBase.js +0 -132
- package/dist/api/ProsopoContractBase.js.map +0 -1
- package/dist/api/ProviderApi.d.ts +0 -17
- package/dist/api/ProviderApi.d.ts.map +0 -1
- package/dist/api/ProviderApi.js +0 -56
- package/dist/api/ProviderApi.js.map +0 -1
- package/dist/api/handlers.d.ts +0 -5
- package/dist/api/handlers.d.ts.map +0 -1
- package/dist/api/handlers.js +0 -13
- package/dist/api/handlers.js.map +0 -1
- package/dist/api/index.d.ts +0 -8
- package/dist/api/index.d.ts.map +0 -1
- package/dist/api/index.js +0 -26
- package/dist/api/index.js.map +0 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -22
- package/dist/index.js.map +0 -1
- package/dist/modules/ProsopoCaptchaApi.d.ts +0 -20
- package/dist/modules/ProsopoCaptchaApi.d.ts.map +0 -1
- package/dist/modules/ProsopoCaptchaApi.js +0 -108
- package/dist/modules/ProsopoCaptchaApi.js.map +0 -1
- package/dist/modules/ProsopoCaptchaClient.d.ts +0 -26
- package/dist/modules/ProsopoCaptchaClient.d.ts.map +0 -1
- package/dist/modules/ProsopoCaptchaClient.js +0 -112
- package/dist/modules/ProsopoCaptchaClient.js.map +0 -1
- package/dist/modules/ProsopoCaptchaStateClient.d.ts +0 -18
- package/dist/modules/ProsopoCaptchaStateClient.d.ts.map +0 -1
- package/dist/modules/ProsopoCaptchaStateClient.js +0 -107
- package/dist/modules/ProsopoCaptchaStateClient.js.map +0 -1
- package/dist/modules/client.d.ts +0 -9
- package/dist/modules/client.d.ts.map +0 -1
- package/dist/modules/client.js +0 -40
- package/dist/modules/client.js.map +0 -1
- package/dist/modules/contract.d.ts +0 -7
- package/dist/modules/contract.d.ts.map +0 -1
- package/dist/modules/contract.js +0 -42
- package/dist/modules/contract.js.map +0 -1
- package/dist/modules/extension.d.ts +0 -3
- package/dist/modules/extension.d.ts.map +0 -1
- package/dist/modules/extension.js +0 -31
- package/dist/modules/extension.js.map +0 -1
- package/dist/modules/index.d.ts +0 -8
- package/dist/modules/index.d.ts.map +0 -1
- package/dist/modules/index.js +0 -26
- package/dist/modules/index.js.map +0 -1
- package/dist/modules/storage.d.ts +0 -14
- package/dist/modules/storage.d.ts.map +0 -1
- package/dist/modules/storage.js +0 -35
- package/dist/modules/storage.js.map +0 -1
- package/dist/types/api.d.ts +0 -38
- package/dist/types/api.d.ts.map +0 -1
- package/dist/types/api.js +0 -22
- package/dist/types/api.js.map +0 -1
- package/dist/types/client.d.ts +0 -61
- package/dist/types/client.d.ts.map +0 -1
- package/dist/types/client.js +0 -3
- package/dist/types/client.js.map +0 -1
- package/dist/types/contract.d.ts +0 -5
- package/dist/types/contract.d.ts.map +0 -1
- package/dist/types/contract.js +0 -3
- package/dist/types/contract.js.map +0 -1
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -22
- package/dist/types/index.js.map +0 -1
- package/tsconfig.tsbuildinfo +0 -1
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# Procaptcha
|
|
2
2
|
|
|
3
|
-
Contains interfaces for accessing the Prosopo [protocol](https://github.com/prosopo
|
|
3
|
+
Contains interfaces for accessing the Prosopo [protocol](https://github.com/prosopo/protocol/) contract, Prosopo [provider](https://github.com/prosopo/provider) API and the captcha client state via the `ProsopoCaptchaClient`, `ProsopoCaptchaApi` and `ProsopoCaptchaStateClient` classes.
|
|
4
4
|
|
|
5
5
|
## Prerequisites
|
|
6
6
|
|
|
7
|
-
The Dapp smart contract account must be [registered](https://github.com/prosopo
|
|
7
|
+
The Dapp smart contract account must be [registered](https://github.com/prosopo/protocol/blob/5cb282a911522bfbf29d34d1830badee3eecec83/contracts/lib.rs#L698-L737) in the Prosopo [protocol](https://github.com/prosopo/protocol/) contract in order to interact with the Prosopo protocol. You can complete Dapp registration by navigating to [polkadot-js apps](https://polkadot.js.org/apps/) and using the contracts page.
|
|
8
8
|
|
|
9
9
|

|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
-
This repository can be imported into any JavaScript framework and used to create a CAPTCHA User Interface. See, for example, the [procaptcha-react](https://github.com/prosopo
|
|
13
|
+
This repository can be imported into any JavaScript framework and used to create a CAPTCHA User Interface. See, for example, the [procaptcha-react](https://github.com/prosopo/procaptcha-react) repository.
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AccountCreator = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
// Copyright (C) 2021-2022 Prosopo (UK) Ltd.
|
|
6
|
-
// This file is part of procaptcha <https://github.com/prosopo
|
|
6
|
+
// This file is part of procaptcha <https://github.com/prosopo/procaptcha>.
|
|
7
7
|
//
|
|
8
8
|
// procaptcha is free software: you can redistribute it and/or modify
|
|
9
9
|
// it under the terms of the GNU General Public License as published by
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccountCreator.js","sourceRoot":"","sources":["../../src/api/AccountCreator.ts"],"names":[],"mappings":";;;;AAAA,4CAA4C;AAC5C,
|
|
1
|
+
{"version":3,"file":"AccountCreator.js","sourceRoot":"","sources":["../../src/api/AccountCreator.ts"],"names":[],"mappings":";;;;AAAA,4CAA4C;AAC5C,2EAA2E;AAC3E,EAAE;AACF,qEAAqE;AACrE,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,gEAAgE;AAChE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,sEAAsE;AACtE,uCAAyC;AAEzC,0EAA0C;AAC1C,+CAAwE;AAExE,uDAAwE;AAGxE,MAAa,cAAe,SAAQ,sBAAY;IAElC,GAAG,CAAa;IAE1B;;OAEG;IACI,KAAK,CAAC,IAAI,CAAC,iBAAoC;QAClD,IAAI,CAAC,GAAG,GAAG,MAAM,gBAAU,CAAC,MAAM,CAAC,EAAC,QAAQ,EAAE,iBAAiB,EAAC,CAAC,CAAC;QAClE,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,KAAK,CAAC,gBAAgB,CAAC,OAAgB;QAC1C,MAAM,IAAA,6BAAe,GAAE,CAAC;QACxB,MAAM,QAAQ,GAAG,IAAA,8BAAgB,GAAE,CAAC;QACpC,OAAO,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAA;IAC5C,CAAC;IAEM,KAAK,CAAC,aAAa,CAAC,OAAiB,EAAE,OAAgB;QAC1D,MAAM,MAAM,GAAG,YAAY,CAAC;QAE5B,IAAI,CAAC,OAAO,EAAE;YACV,OAAO,GAAG,IAAI,iBAAO,CAAC,EAAC,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,EAAC,CAAC,CAAC;SACrF;QAGD,IAAI,OAAO,EAAE;YACT,OAAO,EAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,EAAC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAC,EAAC,CAAA;SAC3D;aAAM;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;YACrD,OAAO;gBACH,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,KAAK,EAAE;oBAClC,CAAC,CAAC,OAAO,CAAC,OAAO;oBACjB,CAAC,CAAC,IAAA,uBAAa,EAAC,IAAA,uBAAa,EAAC,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC;gBAChF,IAAI,EAAE,EAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,EAAC;aACxC,CAAA;SACJ;IAGL,CAAC;CAEJ;AAzCD,wCAyCC"}
|
|
@@ -65,11 +65,11 @@ class ExtensionWeb2 extends AsyncFactory_1.default {
|
|
|
65
65
|
}
|
|
66
66
|
setAccount(address) {
|
|
67
67
|
if (!this.accounts.length) {
|
|
68
|
-
throw new contract_1.ProsopoEnvError("
|
|
68
|
+
throw new contract_1.ProsopoEnvError("WIDGET.NO_ACCOUNTS_FOUND");
|
|
69
69
|
}
|
|
70
70
|
const account = this.accounts.find(acc => acc.address === address);
|
|
71
71
|
if (!account) {
|
|
72
|
-
throw new contract_1.ProsopoEnvError("
|
|
72
|
+
throw new contract_1.ProsopoEnvError("WIDGET.ACCOUNT_NOT_FOUND");
|
|
73
73
|
}
|
|
74
74
|
this.account = account;
|
|
75
75
|
storage_1.default.setAccount(account.address);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtensionWeb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B,iBAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAC3B,CAAC;IAEM,iBAAiB;QACpB,MAAM,cAAc,GAAG,iBAAO,CAAC,UAAU,EAAE,CAAC;QAC5C,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,KAAK,cAAc,CAAC,CAAC;IACrE,CAAC;IAEM,iBAAiB;QACpB,MAAM,cAAc,GAAG,iBAAO,CAAC,UAAU,EAAE,CAAC;QAC5C,IAAI,cAAc,EAAE;YAChB,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;SACnC;IACL,CAAC;IAEM,KAAK,CAAC,aAAa;QACtB,MAAM,cAAc,GAAG,MAAM,+BAAc,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACpE,MAAM,aAAa,GAAG,iBAAO,CAAC,UAAU,EAAE,CAAC;QAC3C,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,aAAa,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;QAC5E,MAAM,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,CAAA;QACjC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAChC,OAAO,OAAO,CAAA;IAClB,CAAC;CAEJ;AA7GD,sCA6GC;AAED,kBAAe,aAAa,CAAC"}
|
|
@@ -1,21 +1,53 @@
|
|
|
1
1
|
import { InjectedAccountWithMeta, InjectedExtension } from "@polkadot/extension-inject/types";
|
|
2
2
|
import { IExtensionInterface } from "../types/client";
|
|
3
3
|
import AsyncFactory from "./AsyncFactory";
|
|
4
|
+
/**
|
|
5
|
+
* Class to discover web3 accounts from browser extensions
|
|
6
|
+
*/
|
|
4
7
|
export declare class ExtensionWeb3 extends AsyncFactory implements IExtensionInterface {
|
|
5
|
-
private extension
|
|
8
|
+
private extension?;
|
|
6
9
|
private account;
|
|
7
10
|
private accounts;
|
|
8
11
|
private injectedExtensions;
|
|
9
12
|
init(): Promise<this>;
|
|
10
13
|
checkExtension(): Promise<void>;
|
|
11
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Get the extension for the selected account.
|
|
16
|
+
* @returns the extension holding the selected account. Undefined if no account selected.
|
|
17
|
+
*/
|
|
18
|
+
getExtension(): InjectedExtension | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Set the extension for the selected account.
|
|
21
|
+
*/
|
|
12
22
|
private setExtension;
|
|
23
|
+
/**
|
|
24
|
+
* Get all accounts across all extensions.
|
|
25
|
+
* @returns all accounts across all extensions.
|
|
26
|
+
*/
|
|
13
27
|
getAccounts(): InjectedAccountWithMeta[];
|
|
28
|
+
/**
|
|
29
|
+
* Discover accounts across all extensions.
|
|
30
|
+
*/
|
|
14
31
|
private setAccounts;
|
|
32
|
+
/**
|
|
33
|
+
* Get the selected account.
|
|
34
|
+
* @returns the selected account.
|
|
35
|
+
*/
|
|
15
36
|
getAccount(): InjectedAccountWithMeta | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Set the selected account.
|
|
39
|
+
* @param address the address of the account to be selected.
|
|
40
|
+
*/
|
|
16
41
|
setAccount(address: string): void;
|
|
17
42
|
unsetAccount(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Get the last used account via the address held in local storage.
|
|
45
|
+
* @returns the account associated with the address held in storage.
|
|
46
|
+
*/
|
|
18
47
|
getDefaultAccount(): InjectedAccountWithMeta | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Select the account using the last used account address held in local storage.
|
|
50
|
+
*/
|
|
19
51
|
setDefaultAccount(): void;
|
|
20
52
|
createAccount(): Promise<undefined>;
|
|
21
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtensionWeb3.d.ts","sourceRoot":"","sources":["../../src/api/ExtensionWeb3.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AAE7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,YAAY,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"ExtensionWeb3.d.ts","sourceRoot":"","sources":["../../src/api/ExtensionWeb3.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AAE7F,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAG1C;;GAEG;AACH,qBAAa,aAAc,SAAQ,YAAa,YAAW,mBAAmB;IAG1E,OAAO,CAAC,SAAS,CAAC,CAAoB;IAEtC,OAAO,CAAC,OAAO,CAAsC;IAErD,OAAO,CAAC,QAAQ,CAA4B;IAE5C,OAAO,CAAC,kBAAkB,CAAsB;IAEnC,IAAI;IAOJ,cAAc;IAW3B;;;OAGG;IACI,YAAY;IAInB;;OAEG;YACW,YAAY;IAY1B;;;OAGG;IACI,WAAW;IAIlB;;OAEG;YACW,WAAW;IAczB;;;OAGG;IACI,UAAU;IAIjB;;;OAGG;IACI,UAAU,CAAC,OAAO,EAAE,MAAM;IAY1B,YAAY;IAMnB;;;OAGG;IACI,iBAAiB;IAKxB;;OAEG;IACI,iBAAiB;IAOX,aAAa;CAY7B;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ExtensionWeb3 = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
// Copyright (C) 2021-2022 Prosopo (UK) Ltd.
|
|
6
|
-
// This file is part of procaptcha <https://github.com/prosopo
|
|
6
|
+
// This file is part of procaptcha <https://github.com/prosopo/procaptcha>.
|
|
7
7
|
//
|
|
8
8
|
// procaptcha is free software: you can redistribute it and/or modify
|
|
9
9
|
// it under the terms of the GNU General Public License as published by
|
|
@@ -21,10 +21,17 @@ const extension_dapp_1 = require("@polkadot/extension-dapp");
|
|
|
21
21
|
const storage_1 = tslib_1.__importDefault(require("../modules/storage"));
|
|
22
22
|
const AsyncFactory_1 = tslib_1.__importDefault(require("./AsyncFactory"));
|
|
23
23
|
const contract_1 = require("@prosopo/contract");
|
|
24
|
+
/**
|
|
25
|
+
* Class to discover web3 accounts from browser extensions
|
|
26
|
+
*/
|
|
24
27
|
class ExtensionWeb3 extends AsyncFactory_1.default {
|
|
28
|
+
// the extension for the currently selected account, if any
|
|
25
29
|
extension;
|
|
30
|
+
// the currently selected account, if any
|
|
26
31
|
account;
|
|
32
|
+
// the discovered accounts
|
|
27
33
|
accounts;
|
|
34
|
+
// the discovered extensions
|
|
28
35
|
injectedExtensions;
|
|
29
36
|
async init() {
|
|
30
37
|
await this.checkExtension();
|
|
@@ -40,12 +47,19 @@ class ExtensionWeb3 extends AsyncFactory_1.default {
|
|
|
40
47
|
throw new contract_1.ProsopoEnvError(err);
|
|
41
48
|
}
|
|
42
49
|
if (!this.injectedExtensions.length) {
|
|
43
|
-
throw new contract_1.ProsopoEnvError("
|
|
50
|
+
throw new contract_1.ProsopoEnvError("WIDGET.NO_EXTENSION_FOUND");
|
|
44
51
|
}
|
|
45
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Get the extension for the selected account.
|
|
55
|
+
* @returns the extension holding the selected account. Undefined if no account selected.
|
|
56
|
+
*/
|
|
46
57
|
getExtension() {
|
|
47
58
|
return this.extension;
|
|
48
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Set the extension for the selected account.
|
|
62
|
+
*/
|
|
49
63
|
async setExtension() {
|
|
50
64
|
try {
|
|
51
65
|
// https://polkadot.js.org/docs/extension/cookbook/
|
|
@@ -55,43 +69,71 @@ class ExtensionWeb3 extends AsyncFactory_1.default {
|
|
|
55
69
|
throw new contract_1.ProsopoEnvError(err);
|
|
56
70
|
}
|
|
57
71
|
if (!this.extension) {
|
|
58
|
-
throw new contract_1.ProsopoEnvError("
|
|
72
|
+
throw new contract_1.ProsopoEnvError("WIDGET.EXTENSION_NOT_FOUND");
|
|
59
73
|
}
|
|
60
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* Get all accounts across all extensions.
|
|
77
|
+
* @returns all accounts across all extensions.
|
|
78
|
+
*/
|
|
61
79
|
getAccounts() {
|
|
62
80
|
return this.accounts;
|
|
63
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Discover accounts across all extensions.
|
|
84
|
+
*/
|
|
64
85
|
async setAccounts() {
|
|
65
|
-
|
|
66
|
-
|
|
86
|
+
this.accounts = await (0, extension_dapp_1.web3Accounts)();
|
|
87
|
+
// get the last used account address from storage
|
|
88
|
+
const lastUsedAccountAddress = storage_1.default.getAccount();
|
|
89
|
+
// lookup this account in the discovered accounts
|
|
90
|
+
const account = this.accounts.find(acc => acc.address === lastUsedAccountAddress);
|
|
91
|
+
// if found then set it
|
|
92
|
+
if (account) {
|
|
93
|
+
this.account = account;
|
|
67
94
|
}
|
|
68
|
-
|
|
69
|
-
|
|
95
|
+
else {
|
|
96
|
+
this.account = undefined;
|
|
70
97
|
}
|
|
71
|
-
this.setDefaultAccount();
|
|
72
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Get the selected account.
|
|
101
|
+
* @returns the selected account.
|
|
102
|
+
*/
|
|
73
103
|
getAccount() {
|
|
74
104
|
return this.account;
|
|
75
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Set the selected account.
|
|
108
|
+
* @param address the address of the account to be selected.
|
|
109
|
+
*/
|
|
76
110
|
setAccount(address) {
|
|
77
111
|
if (!this.accounts.length) {
|
|
78
|
-
throw new contract_1.ProsopoEnvError("
|
|
112
|
+
throw new contract_1.ProsopoEnvError("WIDGET.NO_ACCOUNTS_FOUND");
|
|
79
113
|
}
|
|
80
114
|
const account = this.accounts.find(acc => acc.address === address);
|
|
81
115
|
if (!account) {
|
|
82
|
-
throw new contract_1.ProsopoEnvError("
|
|
116
|
+
throw new contract_1.ProsopoEnvError("WIDGET.ACCOUNT_NOT_FOUND");
|
|
83
117
|
}
|
|
84
118
|
this.account = account;
|
|
85
119
|
storage_1.default.setAccount(account.address);
|
|
86
120
|
}
|
|
87
121
|
unsetAccount() {
|
|
88
122
|
this.account = undefined;
|
|
123
|
+
// update the last used account to empty
|
|
89
124
|
storage_1.default.setAccount("");
|
|
90
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Get the last used account via the address held in local storage.
|
|
128
|
+
* @returns the account associated with the address held in storage.
|
|
129
|
+
*/
|
|
91
130
|
getDefaultAccount() {
|
|
92
131
|
const defaultAccount = storage_1.default.getAccount();
|
|
93
132
|
return this.accounts.find(acc => acc.address === defaultAccount);
|
|
94
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Select the account using the last used account address held in local storage.
|
|
136
|
+
*/
|
|
95
137
|
setDefaultAccount() {
|
|
96
138
|
const defaultAccount = storage_1.default.getAccount();
|
|
97
139
|
if (defaultAccount) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtensionWeb3.js","sourceRoot":"","sources":["../../src/api/ExtensionWeb3.ts"],"names":[],"mappings":";;;;AAAA,4CAA4C;AAC5C,
|
|
1
|
+
{"version":3,"file":"ExtensionWeb3.js","sourceRoot":"","sources":["../../src/api/ExtensionWeb3.ts"],"names":[],"mappings":";;;;AAAA,4CAA4C;AAC5C,2EAA2E;AAC3E,EAAE;AACF,qEAAqE;AACrE,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,gEAAgE;AAChE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,sEAAsE;AACtE,6DAAqG;AAErG,yEAAyC;AAEzC,0EAA0C;AAC1C,gDAAkD;AAElD;;GAEG;AACH,MAAa,aAAc,SAAQ,sBAAY;IAE3C,2DAA2D;IACnD,SAAS,CAAqB;IACtC,yCAAyC;IACjC,OAAO,CAAsC;IACrD,0B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EG;IACI,iBAAiB;QACpB,MAAM,cAAc,GAAG,iBAAO,CAAC,UAAU,EAAE,CAAC;QAC5C,IAAI,cAAc,EAAE;YAChB,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;SACnC;IACL,CAAC;IAEM,KAAK,CAAC,aAAa;QACtB,OAAO,SAAS,CAAA;IACpB,CAAC;CAUJ;AA1ID,sCA0IC;AAED,kBAAe,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/procaptcha",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"author": "PROSOPO LIMITED <info@prosopo.io>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -15,14 +15,15 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@polkadot/api": "^8.13.1",
|
|
17
17
|
"@polkadot/api-contract": "^8.13.1",
|
|
18
|
-
"@polkadot/extension-dapp": "
|
|
19
|
-
"@polkadot/extension-base": "
|
|
20
|
-
"@polkadot/extension-inject": "
|
|
18
|
+
"@polkadot/extension-dapp": "0.44.1",
|
|
19
|
+
"@polkadot/extension-base": "0.44.1",
|
|
20
|
+
"@polkadot/extension-inject": "0.44.1",
|
|
21
21
|
"@polkadot/rpc-provider": "^8.13.1",
|
|
22
22
|
"@polkadot/types": "^8.13.1",
|
|
23
23
|
"@polkadot/util": "^10.0.2",
|
|
24
24
|
"@polkadot/util-crypto": "^10.0.2",
|
|
25
|
-
"@prosopo/contract": "0.1.
|
|
25
|
+
"@prosopo/contract": "0.1.8",
|
|
26
|
+
"@prosopo/datasets": "0.1.8",
|
|
26
27
|
"axios": "^0.27.2"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
@@ -38,12 +39,12 @@
|
|
|
38
39
|
"keywords": [],
|
|
39
40
|
"repository": {
|
|
40
41
|
"type": "git",
|
|
41
|
-
"url": "git+https://github.com/prosopo
|
|
42
|
+
"url": "git+https://github.com/prosopo/procaptcha.git"
|
|
42
43
|
},
|
|
43
44
|
"bugs": {
|
|
44
|
-
"url": "https://github.com/prosopo
|
|
45
|
+
"url": "https://github.com/prosopo/procaptcha/issues"
|
|
45
46
|
},
|
|
46
|
-
"homepage": "https://github.com/prosopo
|
|
47
|
+
"homepage": "https://github.com/prosopo/procaptcha#readme",
|
|
47
48
|
"description": "",
|
|
48
49
|
"publishConfig": {
|
|
49
50
|
"registry": "https://registry.npmjs.org"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AsyncFactory.d.ts","sourceRoot":"","sources":["../../src/api/AsyncFactory.ts"],"names":[],"mappings":"AAiBA,8BAAsB,YAAY;;WAMV,MAAM,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;aAIzB,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAEtD;AAED,eAAe,YAAY,CAAC"}
|
package/dist/api/AsyncFactory.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AsyncFactory = void 0;
|
|
4
|
-
// Copyright (C) 2021-2022 Prosopo (UK) Ltd.
|
|
5
|
-
// This file is part of procaptcha <https://github.com/prosopo-io/procaptcha>.
|
|
6
|
-
//
|
|
7
|
-
// procaptcha is free software: you can redistribute it and/or modify
|
|
8
|
-
// it under the terms of the GNU General Public License as published by
|
|
9
|
-
// the Free Software Foundation, either version 3 of the License, or
|
|
10
|
-
// (at your option) any later version.
|
|
11
|
-
//
|
|
12
|
-
// procaptcha is distributed in the hope that it will be useful,
|
|
13
|
-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
-
// GNU General Public License for more details.
|
|
16
|
-
//
|
|
17
|
-
// You should have received a copy of the GNU General Public License
|
|
18
|
-
// along with procaptcha. If not, see <http://www.gnu.org/licenses/>.
|
|
19
|
-
const contract_1 = require("@prosopo/contract");
|
|
20
|
-
class AsyncFactory {
|
|
21
|
-
constructor() {
|
|
22
|
-
throw new contract_1.ProsopoEnvError("Use `create` factory method");
|
|
23
|
-
}
|
|
24
|
-
static async create(...args) {
|
|
25
|
-
return await Object.create(this.prototype).init(...args);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.AsyncFactory = AsyncFactory;
|
|
29
|
-
exports.default = AsyncFactory;
|
|
30
|
-
//# sourceMappingURL=AsyncFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AsyncFactory.js","sourceRoot":"","sources":["../../src/api/AsyncFactory.ts"],"names":[],"mappings":";;;AAAA,4CAA4C;AAC5C,8EAA8E;AAC9E,EAAE;AACF,qEAAqE;AACrE,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,gEAAgE;AAChE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,sEAAsE;AACtE,gDAAkD;AAElD,MAAsB,YAAY;IAE9B;QACI,MAAM,IAAI,0BAAe,CAAC,6BAA6B,CAAC,CAAC;IAC7D,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,IAAW;QACrC,OAAO,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;IAC7D,CAAC;CAIJ;AAZD,oCAYC;AAED,kBAAe,YAAY,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AxiosInstance, AxiosResponse } from "axios";
|
|
2
|
-
export declare class HttpClientBase {
|
|
3
|
-
protected readonly axios: AxiosInstance;
|
|
4
|
-
constructor(baseURL: string, prefix?: string);
|
|
5
|
-
protected responseHandler: (response: AxiosResponse) => any;
|
|
6
|
-
protected errorHandler: (error: any) => Promise<never>;
|
|
7
|
-
}
|
|
8
|
-
export default HttpClientBase;
|
|
9
|
-
//# sourceMappingURL=HttpClientBase.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HttpClientBase.d.ts","sourceRoot":"","sources":["../../src/api/HttpClientBase.ts"],"names":[],"mappings":"AAeA,OAAc,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE5D,qBAAa,cAAc;IAEvB,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;gBAE5B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAK;IAMxC,SAAS,CAAC,eAAe,aAAc,aAAa,SAGnD;IAED,SAAS,CAAC,YAAY,UAAW,GAAG,oBAAoC;CAE3E;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpClientBase = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
// Copyright (C) 2021-2022 Prosopo (UK) Ltd.
|
|
6
|
-
// This file is part of procaptcha <https://github.com/prosopo-io/procaptcha>.
|
|
7
|
-
//
|
|
8
|
-
// procaptcha is free software: you can redistribute it and/or modify
|
|
9
|
-
// it under the terms of the GNU General Public License as published by
|
|
10
|
-
// the Free Software Foundation, either version 3 of the License, or
|
|
11
|
-
// (at your option) any later version.
|
|
12
|
-
//
|
|
13
|
-
// procaptcha is distributed in the hope that it will be useful,
|
|
14
|
-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
-
// GNU General Public License for more details.
|
|
17
|
-
//
|
|
18
|
-
// You should have received a copy of the GNU General Public License
|
|
19
|
-
// along with procaptcha. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
-
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
21
|
-
class HttpClientBase {
|
|
22
|
-
axios;
|
|
23
|
-
constructor(baseURL, prefix = "") {
|
|
24
|
-
baseURL = baseURL + prefix;
|
|
25
|
-
this.axios = axios_1.default.create({ baseURL });
|
|
26
|
-
this.axios.interceptors.response.use(this.responseHandler, this.errorHandler);
|
|
27
|
-
}
|
|
28
|
-
responseHandler = (response) => {
|
|
29
|
-
console.log("API REQUEST", response.request);
|
|
30
|
-
return response.data;
|
|
31
|
-
};
|
|
32
|
-
errorHandler = (error) => Promise.reject(error.response);
|
|
33
|
-
}
|
|
34
|
-
exports.HttpClientBase = HttpClientBase;
|
|
35
|
-
exports.default = HttpClientBase;
|
|
36
|
-
//# sourceMappingURL=HttpClientBase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HttpClientBase.js","sourceRoot":"","sources":["../../src/api/HttpClientBase.ts"],"names":[],"mappings":";;;;AAAA,4CAA4C;AAC5C,8EAA8E;AAC9E,EAAE;AACF,qEAAqE;AACrE,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,gEAAgE;AAChE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,sEAAsE;AACtE,0DAA4D;AAE5D,MAAa,cAAc;IAEJ,KAAK,CAAgB;IAExC,YAAY,OAAe,EAAE,MAAM,GAAG,EAAE;QACpC,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,eAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;QACvC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IAClF,CAAC;IAES,eAAe,GAAG,CAAC,QAAuB,EAAE,EAAE;QACpD,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC7C,OAAO,QAAQ,CAAC,IAAI,CAAC;IACzB,CAAC,CAAA;IAES,YAAY,GAAG,CAAC,KAAU,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;CAE3E;AAjBD,wCAiBC;AAED,kBAAe,cAAc,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import ProsopoContractBase from "./ProsopoContractBase";
|
|
2
|
-
import { Signer } from '@polkadot/api/types';
|
|
3
|
-
import { ProsopoDappOperatorIsHumanUserResponse, TransactionResponse } from '../types';
|
|
4
|
-
import { ProsopoRandomProviderResponse } from "../types";
|
|
5
|
-
import { CaptchaSolutionCommitment } from "@prosopo/contract";
|
|
6
|
-
export declare class ProsopoContract extends ProsopoContractBase {
|
|
7
|
-
getRandomProvider(): Promise<ProsopoRandomProviderResponse>;
|
|
8
|
-
getCaptchaSolutionCommitment(commitmentId: string): Promise<CaptchaSolutionCommitment>;
|
|
9
|
-
dappUserCommit(signer: Signer, captchaDatasetId: string, userMerkleTreeRoot: string, providerAddress: string): Promise<TransactionResponse>;
|
|
10
|
-
dappOperatorIsHumanUser(solutionThreshold: number): Promise<ProsopoDappOperatorIsHumanUserResponse>;
|
|
11
|
-
}
|
|
12
|
-
export default ProsopoContract;
|
|
13
|
-
//# sourceMappingURL=ProsopoContract.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProsopoContract.d.ts","sourceRoot":"","sources":["../../src/api/ProsopoContract.ts"],"names":[],"mappings":"AAgBA,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAC,sCAAsC,EAAE,mBAAmB,EAAC,MAAM,UAAU,CAAC;AACrF,OAAO,EAAE,6BAA6B,EAAE,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAG9D,qBAAa,eAAgB,SAAQ,mBAAmB;IAEvC,iBAAiB,IAAI,OAAO,CAAC,6BAA6B,CAAC;IAI3D,4BAA4B,CAAC,YAAY,EAAE,MAAM;IAIjD,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAI3I,uBAAuB,CAAC,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,sCAAsC,CAAC;CAOnH;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProsopoContract = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
// Copyright (C) 2021-2022 Prosopo (UK) Ltd.
|
|
6
|
-
// This file is part of procaptcha <https://github.com/prosopo-io/procaptcha>.
|
|
7
|
-
//
|
|
8
|
-
// procaptcha is free software: you can redistribute it and/or modify
|
|
9
|
-
// it under the terms of the GNU General Public License as published by
|
|
10
|
-
// the Free Software Foundation, either version 3 of the License, or
|
|
11
|
-
// (at your option) any later version.
|
|
12
|
-
//
|
|
13
|
-
// procaptcha is distributed in the hope that it will be useful,
|
|
14
|
-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
-
// GNU General Public License for more details.
|
|
17
|
-
//
|
|
18
|
-
// You should have received a copy of the GNU General Public License
|
|
19
|
-
// along with procaptcha. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
-
// import {Hash} from '@polkadot/types/interfaces';
|
|
21
|
-
const ProsopoContractBase_1 = tslib_1.__importDefault(require("./ProsopoContractBase"));
|
|
22
|
-
class ProsopoContract extends ProsopoContractBase_1.default {
|
|
23
|
-
async getRandomProvider() {
|
|
24
|
-
return await this.query('getRandomActiveProvider', [this.account.address, this.dappAddress]);
|
|
25
|
-
}
|
|
26
|
-
async getCaptchaSolutionCommitment(commitmentId) {
|
|
27
|
-
return await this.query('getCaptchaSolutionCommitment', [commitmentId]);
|
|
28
|
-
}
|
|
29
|
-
async dappUserCommit(signer, captchaDatasetId, userMerkleTreeRoot, providerAddress) {
|
|
30
|
-
return await this.transaction(signer, 'dappUserCommit', [this.dappAddress, captchaDatasetId, userMerkleTreeRoot, providerAddress]);
|
|
31
|
-
}
|
|
32
|
-
async dappOperatorIsHumanUser(solutionThreshold) {
|
|
33
|
-
return await this.query('dappOperatorIsHumanUser', [this.account.address, solutionThreshold]);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.ProsopoContract = ProsopoContract;
|
|
37
|
-
exports.default = ProsopoContract;
|
|
38
|
-
//# sourceMappingURL=ProsopoContract.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProsopoContract.js","sourceRoot":"","sources":["../../src/api/ProsopoContract.ts"],"names":[],"mappings":";;;;AAAA,4CAA4C;AAC5C,8EAA8E;AAC9E,EAAE;AACF,qEAAqE;AACrE,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,gEAAgE;AAChE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,sEAAsE;AACtE,mDAAmD;AACnD,wFAAwD;AAOxD,MAAa,eAAgB,SAAQ,6BAAmB;IAE7C,KAAK,CAAC,iBAAiB;QAC1B,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,yBAAyB,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAkC,CAAC;IAClI,CAAC;IAEM,KAAK,CAAC,4BAA4B,CAAC,YAAoB;QAC1D,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,8BAA8B,EAAE,CAAC,YAAY,CAAC,CAA8B,CAAC;IACzG,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,MAAc,EAAE,gBAAwB,EAAE,kBAA0B,EAAE,eAAuB;QACrH,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,gBAAgB,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,eAAe,CAAC,CAAC,CAAC;IACvI,CAAC;IAEM,KAAK,CAAC,uBAAuB,CAAC,iBAAyB;QAE1D,OAAO,MAAM,IAAI,CAAC,KAAK,CAAC,yBAAyB,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAA2C,CAAC;IAC5I,CAAC;CAIJ;AArBD,0CAqBC;AAED,kBAAe,eAAe,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { ApiPromise } from "@polkadot/api";
|
|
2
|
-
import { Abi, ContractPromise } from "@polkadot/api-contract";
|
|
3
|
-
import { InjectedAccountWithMeta } from "@polkadot/extension-inject/types";
|
|
4
|
-
import { AnyJson } from "@polkadot/types/types/codec";
|
|
5
|
-
import { ProviderInterface } from "@polkadot/rpc-provider/types";
|
|
6
|
-
import { Signer } from "@polkadot/api/types";
|
|
7
|
-
import { TransactionResponse } from '../types';
|
|
8
|
-
import AsyncFactory from "./AsyncFactory";
|
|
9
|
-
export declare class ProsopoContractBase extends AsyncFactory {
|
|
10
|
-
protected api: ApiPromise;
|
|
11
|
-
protected abi: Abi;
|
|
12
|
-
protected contract: ContractPromise;
|
|
13
|
-
protected account: InjectedAccountWithMeta;
|
|
14
|
-
protected dappAddress: string;
|
|
15
|
-
address: string;
|
|
16
|
-
/**
|
|
17
|
-
* @param address
|
|
18
|
-
* @param dappAddress
|
|
19
|
-
* @param account
|
|
20
|
-
* @param providerInterface
|
|
21
|
-
*/
|
|
22
|
-
init(address: string, dappAddress: string, account: InjectedAccountWithMeta, providerInterface: ProviderInterface): Promise<this>;
|
|
23
|
-
getApi(): ApiPromise;
|
|
24
|
-
getContract(): ContractPromise;
|
|
25
|
-
getAccount(): InjectedAccountWithMeta;
|
|
26
|
-
getDappAddress(): string;
|
|
27
|
-
disconnect(): Promise<void>;
|
|
28
|
-
query<T>(method: string, args: any[]): Promise<T | AnyJson | null>;
|
|
29
|
-
transaction(signer: Signer, method: string, args: any[]): Promise<TransactionResponse>;
|
|
30
|
-
}
|
|
31
|
-
export default ProsopoContractBase;
|
|
32
|
-
//# sourceMappingURL=ProsopoContractBase.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProsopoContractBase.d.ts","sourceRoot":"","sources":["../../src/api/ProsopoContractBase.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAAqB,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAG3E,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAK1C,qBAAa,mBAAoB,SAAQ,YAAY;IAEjD,SAAS,CAAC,GAAG,EAAE,UAAU,CAAC;IAC1B,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC;IACnB,SAAS,CAAC,QAAQ,EAAE,eAAe,CAAC;IACpC,SAAS,CAAC,OAAO,EAAE,uBAAuB,CAAC;IAC3C,SAAS,CAAC,WAAW,EAAE,MAAM,CAAC;IAEvB,OAAO,EAAE,MAA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