@dorafactory/maci-sdk 0.1.3-pre.11 → 0.1.3-pre.13
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 +97 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +97 -0
- package/dist/index.mjs.map +1 -1
- package/dist/libs/maci/maci.d.ts +11 -0
- package/dist/maci.d.ts +13 -0
- package/package.json +1 -1
- package/src/libs/maci/maci.ts +102 -0
- package/src/maci.ts +36 -0
package/dist/index.js
CHANGED
|
@@ -8073,6 +8073,80 @@ var MACI = class {
|
|
|
8073
8073
|
throw Error(`Submit deactivate failed! ${error}`);
|
|
8074
8074
|
}
|
|
8075
8075
|
}
|
|
8076
|
+
async rawDeactivate({
|
|
8077
|
+
signer,
|
|
8078
|
+
address,
|
|
8079
|
+
contractAddress,
|
|
8080
|
+
payload,
|
|
8081
|
+
gasStation,
|
|
8082
|
+
fee = 1.8
|
|
8083
|
+
}) {
|
|
8084
|
+
try {
|
|
8085
|
+
address = address || (await signer.getAccounts())[0].address;
|
|
8086
|
+
const client = await this.contract.contractClient({
|
|
8087
|
+
signer
|
|
8088
|
+
});
|
|
8089
|
+
const { msg, encPubkeys } = payload;
|
|
8090
|
+
const deactivateMsg = stringizing({
|
|
8091
|
+
publish_deactivate_message: {
|
|
8092
|
+
enc_pub_key: {
|
|
8093
|
+
x: encPubkeys[0],
|
|
8094
|
+
y: encPubkeys[1]
|
|
8095
|
+
},
|
|
8096
|
+
message: {
|
|
8097
|
+
data: msg
|
|
8098
|
+
}
|
|
8099
|
+
}
|
|
8100
|
+
});
|
|
8101
|
+
if (gasStation === true && typeof fee !== "object") {
|
|
8102
|
+
const gasEstimation = await client.simulate(
|
|
8103
|
+
address,
|
|
8104
|
+
[
|
|
8105
|
+
{
|
|
8106
|
+
typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
|
|
8107
|
+
value: {
|
|
8108
|
+
sender: address,
|
|
8109
|
+
contract: contractAddress,
|
|
8110
|
+
msg: new TextEncoder().encode(JSON.stringify(deactivateMsg))
|
|
8111
|
+
}
|
|
8112
|
+
}
|
|
8113
|
+
],
|
|
8114
|
+
""
|
|
8115
|
+
);
|
|
8116
|
+
const multiplier = typeof fee === "number" ? fee : 1.8;
|
|
8117
|
+
const gasPrice = import_stargate3.GasPrice.fromString("10000000000peaka");
|
|
8118
|
+
const calculatedFee = (0, import_stargate3.calculateFee)(
|
|
8119
|
+
Math.round(gasEstimation * multiplier),
|
|
8120
|
+
gasPrice
|
|
8121
|
+
);
|
|
8122
|
+
const grantFee = {
|
|
8123
|
+
amount: calculatedFee.amount,
|
|
8124
|
+
gas: calculatedFee.gas,
|
|
8125
|
+
granter: contractAddress
|
|
8126
|
+
};
|
|
8127
|
+
return client.execute(
|
|
8128
|
+
address,
|
|
8129
|
+
contractAddress,
|
|
8130
|
+
deactivateMsg,
|
|
8131
|
+
grantFee
|
|
8132
|
+
);
|
|
8133
|
+
} else if (gasStation === true && typeof fee === "object") {
|
|
8134
|
+
const grantFee = {
|
|
8135
|
+
...fee,
|
|
8136
|
+
granter: contractAddress
|
|
8137
|
+
};
|
|
8138
|
+
return client.execute(
|
|
8139
|
+
address,
|
|
8140
|
+
contractAddress,
|
|
8141
|
+
deactivateMsg,
|
|
8142
|
+
grantFee
|
|
8143
|
+
);
|
|
8144
|
+
}
|
|
8145
|
+
return client.execute(address, contractAddress, deactivateMsg, fee);
|
|
8146
|
+
} catch (error) {
|
|
8147
|
+
throw Error(`Submit deactivate failed! ${error}`);
|
|
8148
|
+
}
|
|
8149
|
+
}
|
|
8076
8150
|
async fetchAllDeactivateLogs({
|
|
8077
8151
|
contractAddress
|
|
8078
8152
|
}) {
|
|
@@ -8779,6 +8853,29 @@ var MaciClient2 = class {
|
|
|
8779
8853
|
fee
|
|
8780
8854
|
});
|
|
8781
8855
|
}
|
|
8856
|
+
async getSignUpEventByPubKey(contractAddress, pubKey) {
|
|
8857
|
+
return await this.indexer.getSignUpEventByPubKey(contractAddress, pubKey);
|
|
8858
|
+
}
|
|
8859
|
+
async fetchAllDeactivateLogs(contractAddress) {
|
|
8860
|
+
return await this.indexer.fetchAllDeactivateLogs(contractAddress);
|
|
8861
|
+
}
|
|
8862
|
+
async rawDeactivate({
|
|
8863
|
+
signer,
|
|
8864
|
+
address,
|
|
8865
|
+
contractAddress,
|
|
8866
|
+
payload,
|
|
8867
|
+
gasStation = false,
|
|
8868
|
+
fee
|
|
8869
|
+
}) {
|
|
8870
|
+
return await this.maci.rawDeactivate({
|
|
8871
|
+
signer: this.getSigner(signer),
|
|
8872
|
+
address,
|
|
8873
|
+
contractAddress,
|
|
8874
|
+
payload,
|
|
8875
|
+
gasStation,
|
|
8876
|
+
fee
|
|
8877
|
+
});
|
|
8878
|
+
}
|
|
8782
8879
|
};
|
|
8783
8880
|
// Annotate the CommonJS export names for ESM import in node:
|
|
8784
8881
|
0 && (module.exports = {
|