@dorafactory/maci-sdk 0.0.19 → 0.0.20
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/dist/browser.d.mts +14 -1
- package/dist/browser.d.ts +14 -1
- package/dist/browser.js +31 -2
- package/dist/browser.js.map +1 -1
- package/dist/browser.mjs +31 -2
- package/dist/browser.mjs.map +1 -1
- package/dist/index.d.mts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +31 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/libs/http/http.ts +2 -1
- package/src/libs/maci/maci.ts +22 -0
- package/src/libs/oracle-certificate/oracle-certificate.ts +16 -0
- package/src/libs/oracle-certificate/types.ts +9 -0
package/package.json
CHANGED
package/src/libs/http/http.ts
CHANGED
|
@@ -116,11 +116,12 @@ export class Http {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
async fetchRest(path: string): Promise<any> {
|
|
119
|
+
async fetchRest(path: string, options?: any): Promise<any> {
|
|
120
120
|
try {
|
|
121
121
|
const fetchFn = this.getFetch();
|
|
122
122
|
const response = await fetchFn(`${this.restEndpoint}${path}`, {
|
|
123
123
|
...this.defaultOptions,
|
|
124
|
+
...options,
|
|
124
125
|
});
|
|
125
126
|
|
|
126
127
|
if (!response.ok) {
|
package/src/libs/maci/maci.ts
CHANGED
|
@@ -107,6 +107,28 @@ export class MACI {
|
|
|
107
107
|
return response.data.signUpEvents[0].stateIdx;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
async feegrantAllowance({
|
|
111
|
+
address,
|
|
112
|
+
contractAddress,
|
|
113
|
+
}: {
|
|
114
|
+
address: string;
|
|
115
|
+
contractAddress: string;
|
|
116
|
+
}) {
|
|
117
|
+
try {
|
|
118
|
+
const response = await this.oracleCertificate.feegrantAllowance(
|
|
119
|
+
contractAddress,
|
|
120
|
+
address
|
|
121
|
+
);
|
|
122
|
+
return response;
|
|
123
|
+
} catch (error) {
|
|
124
|
+
return {
|
|
125
|
+
granter: contractAddress,
|
|
126
|
+
grantee: address,
|
|
127
|
+
spend_limit: [],
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
110
132
|
// only for maci and oracle maci, amaci will set the voice credit when deploy the contract
|
|
111
133
|
async queryWhitelistBalanceOf({
|
|
112
134
|
signer,
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
OracleCertificateParams,
|
|
4
4
|
SignatureRequest,
|
|
5
5
|
SignatureResponse,
|
|
6
|
+
FeegrantAllowanceResponse,
|
|
6
7
|
} from './types';
|
|
7
8
|
|
|
8
9
|
export class OracleCertificate {
|
|
@@ -33,4 +34,19 @@ export class OracleCertificate {
|
|
|
33
34
|
|
|
34
35
|
return signatureData;
|
|
35
36
|
}
|
|
37
|
+
|
|
38
|
+
async feegrantAllowance(
|
|
39
|
+
granter: string,
|
|
40
|
+
grantee: string
|
|
41
|
+
): Promise<FeegrantAllowanceResponse> {
|
|
42
|
+
const response = await this.http.fetchRest(
|
|
43
|
+
`/cosmos/feegrant/v1beta1/allowance/${granter}/${grantee}`
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
granter,
|
|
48
|
+
grantee,
|
|
49
|
+
spend_limit: response.allowance.allowance.allowance.spend_limit,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
36
52
|
}
|