@dorafactory/maci-sdk 0.1.3-pre.15 → 0.1.3-pre.16
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/index.js +81 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +81 -3
- package/dist/index.mjs.map +1 -1
- package/dist/libs/maci/maci.d.ts +5 -2
- package/dist/maci.d.ts +7 -4
- package/package.json +1 -1
- package/src/libs/maci/maci.ts +85 -3
- package/src/maci.ts +11 -2
package/dist/index.js
CHANGED
|
@@ -8078,7 +8078,8 @@ var MACI = class {
|
|
|
8078
8078
|
address,
|
|
8079
8079
|
contractAddress,
|
|
8080
8080
|
payload,
|
|
8081
|
-
gasStation,
|
|
8081
|
+
gasStation = false,
|
|
8082
|
+
granter,
|
|
8082
8083
|
fee = 1.8
|
|
8083
8084
|
}) {
|
|
8084
8085
|
try {
|
|
@@ -8122,7 +8123,7 @@ var MACI = class {
|
|
|
8122
8123
|
const grantFee = {
|
|
8123
8124
|
amount: calculatedFee.amount,
|
|
8124
8125
|
gas: calculatedFee.gas,
|
|
8125
|
-
granter: contractAddress
|
|
8126
|
+
granter: granter || contractAddress
|
|
8126
8127
|
};
|
|
8127
8128
|
return client.execute(
|
|
8128
8129
|
address,
|
|
@@ -8133,7 +8134,7 @@ var MACI = class {
|
|
|
8133
8134
|
} else if (gasStation === true && typeof fee === "object") {
|
|
8134
8135
|
const grantFee = {
|
|
8135
8136
|
...fee,
|
|
8136
|
-
granter: contractAddress
|
|
8137
|
+
granter: granter || contractAddress
|
|
8137
8138
|
};
|
|
8138
8139
|
return client.execute(
|
|
8139
8140
|
address,
|
|
@@ -8208,12 +8209,83 @@ var MACI = class {
|
|
|
8208
8209
|
proof,
|
|
8209
8210
|
nullifier,
|
|
8210
8211
|
newPubkey,
|
|
8212
|
+
gasStation = false,
|
|
8213
|
+
granter,
|
|
8211
8214
|
fee = "auto"
|
|
8212
8215
|
}) {
|
|
8213
8216
|
const client = await this.contract.amaciClient({
|
|
8214
8217
|
signer,
|
|
8215
8218
|
contractAddress
|
|
8216
8219
|
});
|
|
8220
|
+
if (gasStation === true && typeof fee !== "object") {
|
|
8221
|
+
const [{ address }] = await signer.getAccounts();
|
|
8222
|
+
const contractClient = await this.contract.contractClient({ signer });
|
|
8223
|
+
const msg = {
|
|
8224
|
+
add_new_key: {
|
|
8225
|
+
d,
|
|
8226
|
+
groth16_proof: proof,
|
|
8227
|
+
nullifier: nullifier.toString(),
|
|
8228
|
+
pubkey: {
|
|
8229
|
+
x: newPubkey[0].toString(),
|
|
8230
|
+
y: newPubkey[1].toString()
|
|
8231
|
+
}
|
|
8232
|
+
}
|
|
8233
|
+
};
|
|
8234
|
+
const gasEstimation = await contractClient.simulate(
|
|
8235
|
+
address,
|
|
8236
|
+
[
|
|
8237
|
+
{
|
|
8238
|
+
typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
|
|
8239
|
+
value: {
|
|
8240
|
+
sender: address,
|
|
8241
|
+
contract: contractAddress,
|
|
8242
|
+
msg: new TextEncoder().encode(JSON.stringify(msg))
|
|
8243
|
+
}
|
|
8244
|
+
}
|
|
8245
|
+
],
|
|
8246
|
+
""
|
|
8247
|
+
);
|
|
8248
|
+
const multiplier = typeof fee === "number" ? fee : 1.8;
|
|
8249
|
+
const gasPrice = import_stargate3.GasPrice.fromString("10000000000peaka");
|
|
8250
|
+
const calculatedFee = (0, import_stargate3.calculateFee)(
|
|
8251
|
+
Math.round(gasEstimation * multiplier),
|
|
8252
|
+
gasPrice
|
|
8253
|
+
);
|
|
8254
|
+
const grantFee = {
|
|
8255
|
+
amount: calculatedFee.amount,
|
|
8256
|
+
gas: calculatedFee.gas,
|
|
8257
|
+
granter: granter || contractAddress
|
|
8258
|
+
};
|
|
8259
|
+
return await client.addNewKey(
|
|
8260
|
+
{
|
|
8261
|
+
d,
|
|
8262
|
+
groth16Proof: proof,
|
|
8263
|
+
nullifier: nullifier.toString(),
|
|
8264
|
+
pubkey: {
|
|
8265
|
+
x: newPubkey[0].toString(),
|
|
8266
|
+
y: newPubkey[1].toString()
|
|
8267
|
+
}
|
|
8268
|
+
},
|
|
8269
|
+
grantFee
|
|
8270
|
+
);
|
|
8271
|
+
} else if (gasStation === true && typeof fee === "object") {
|
|
8272
|
+
const grantFee = {
|
|
8273
|
+
...fee,
|
|
8274
|
+
granter: granter || contractAddress
|
|
8275
|
+
};
|
|
8276
|
+
return await client.addNewKey(
|
|
8277
|
+
{
|
|
8278
|
+
d,
|
|
8279
|
+
groth16Proof: proof,
|
|
8280
|
+
nullifier: nullifier.toString(),
|
|
8281
|
+
pubkey: {
|
|
8282
|
+
x: newPubkey[0].toString(),
|
|
8283
|
+
y: newPubkey[1].toString()
|
|
8284
|
+
}
|
|
8285
|
+
},
|
|
8286
|
+
grantFee
|
|
8287
|
+
);
|
|
8288
|
+
}
|
|
8217
8289
|
return await client.addNewKey(
|
|
8218
8290
|
{
|
|
8219
8291
|
d,
|
|
@@ -8891,6 +8963,7 @@ var MaciClient2 = class {
|
|
|
8891
8963
|
contractAddress,
|
|
8892
8964
|
payload,
|
|
8893
8965
|
gasStation = false,
|
|
8966
|
+
granter,
|
|
8894
8967
|
fee
|
|
8895
8968
|
}) {
|
|
8896
8969
|
return await this.maci.rawDeactivate({
|
|
@@ -8899,6 +8972,7 @@ var MaciClient2 = class {
|
|
|
8899
8972
|
contractAddress,
|
|
8900
8973
|
payload,
|
|
8901
8974
|
gasStation,
|
|
8975
|
+
granter,
|
|
8902
8976
|
fee
|
|
8903
8977
|
});
|
|
8904
8978
|
}
|
|
@@ -8909,6 +8983,8 @@ var MaciClient2 = class {
|
|
|
8909
8983
|
proof,
|
|
8910
8984
|
nullifier,
|
|
8911
8985
|
newPubkey,
|
|
8986
|
+
gasStation = false,
|
|
8987
|
+
granter,
|
|
8912
8988
|
fee
|
|
8913
8989
|
}) {
|
|
8914
8990
|
return await this.maci.rawAddNewKey({
|
|
@@ -8918,6 +8994,8 @@ var MaciClient2 = class {
|
|
|
8918
8994
|
proof,
|
|
8919
8995
|
nullifier,
|
|
8920
8996
|
newPubkey,
|
|
8997
|
+
gasStation,
|
|
8998
|
+
granter,
|
|
8921
8999
|
fee
|
|
8922
9000
|
});
|
|
8923
9001
|
}
|