本文整理汇总了TypeScript中@counterfactual/cf.js.utils.signaturesToBytes方法的典型用法代码示例。如果您正苦于以下问题:TypeScript js.utils.signaturesToBytes方法的具体用法?TypeScript js.utils.signaturesToBytes怎么用?TypeScript js.utils.signaturesToBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@counterfactual/cf.js.utils
的用法示例。
在下文中一共展示了js.utils.signaturesToBytes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: setCommitment
/**
* Sets the commitment at the end of a protocol's execution.
* @param internalMessage
* @param next
* @param context
* @throws Error if the counterparty's signature is not set
*/
public async setCommitment(
internalMessage: InternalMessage,
next: Function,
context: Context
) {
let appId;
const action: cf.legacy.node.ActionName = internalMessage.actionName;
const operation = context.intermediateResults.operation!;
let appCommitments: AppCommitments;
const incomingMessage = this.incomingMessage(internalMessage, context);
if (action === cf.legacy.node.ActionName.SETUP) {
appId = internalMessage.clientMessage.multisigAddress;
} else if (action === cf.legacy.node.ActionName.INSTALL) {
const proposal = context.intermediateResults.proposedStateTransition!;
appId = proposal.cfAddr;
} else {
appId = internalMessage.clientMessage.appId;
}
if (this.store.has(appId)) {
appCommitments = AppCommitments.deserialize(appId, this.store.get(appId));
} else {
appCommitments = new AppCommitments(appId);
this.appCount += 1;
this.store.put(appId, Object(appCommitments.serialize()));
}
const signature = context.intermediateResults.signature!;
const counterpartySignature = incomingMessage!.signature!;
if (
counterpartySignature === undefined ||
cf.utils.signaturesToBytes(signature) ===
cf.utils.signaturesToBytes(counterpartySignature)
) {
// FIXME: these errors should be handled more gracefully
// https://github.com/counterfactual/monorepo/issues/99
throw Error(
`Cannot make commitment for operation ${action}.
The counterparty hasn't signed the commitment.`
);
}
await appCommitments.addCommitment(action, operation, [
signature,
counterpartySignature
]);
this.store.put(appId, Object(appCommitments.serialize()));
next();
}
示例2: constructSetStateData
function constructSetStateData(signatures: ethers.utils.Signature[]): string {
return constructContractCall(
"proxyCall(address,bytes32,bytes)",
TEST_NETWORK_CONTEXT.registryAddr,
TEST_APP_INSTANCE.cfAddress(),
constructContractCall(
"setState(bytes32,uint256,uint256,bytes)",
TEST_APP_STATE_HASH,
TEST_LOCAL_NONCE,
TEST_TIMEOUT,
cf.utils.signaturesToBytes(...signatures)
)
);
}
示例3: constructMultisigExecTransaction
export function constructMultisigExecTransaction(
operation: "delegatecall" | "call",
to: string,
value: string | number,
transactionData: string,
signatures: ethers.utils.Signature[]
): string {
return constructContractCall(
"execTransaction(address, uint256, bytes, uint8, bytes)",
to,
value,
transactionData,
operation === "delegatecall" ? 1 : 0,
cf.utils.signaturesToBytes(...signatures)
);
}