@canvas-js/interfaces
Advanced tools
Comparing version 0.0.16 to 0.0.17-alpha
@@ -25,4 +25,1 @@ import type { Chain, ChainId } from "./contracts.js"; | ||
}; | ||
export declare type ActionResult = { | ||
hash: string; | ||
}; |
@@ -6,4 +6,4 @@ import type { Block } from "./actions.js"; | ||
timestamp: number; | ||
session_public_key: string; | ||
session_duration: number; | ||
address: string; | ||
duration: number; | ||
block?: Block; | ||
@@ -10,0 +10,0 @@ }; |
@@ -11,10 +11,32 @@ import { utils } from "ethers"; | ||
}; | ||
function serializeActionArgument(arg) { | ||
if (typeof arg === "number") { | ||
if (isNaN(arg)) { | ||
return "NaN"; | ||
} | ||
else if (Object.is(arg, -0)) { | ||
return "-0"; | ||
} | ||
else if (arg === Infinity) { | ||
return "Infinity"; | ||
} | ||
else if (arg === -Infinity) { | ||
return "-Infinity"; | ||
} | ||
else { | ||
return arg.toString(); | ||
} | ||
} | ||
else { | ||
return JSON.stringify(arg); | ||
} | ||
} | ||
export function getActionSignatureData(payload) { | ||
const domain = { | ||
name: "Canvas", | ||
salt: utils.hexlify(utils.zeroPad(utils.arrayify(payload.from), 32)), | ||
salt: utils.hexlify(utils.zeroPad(utils.arrayify(payload.from), 32)).toLowerCase(), | ||
}; | ||
const actionValue = { | ||
sendAction: payload.call, | ||
params: payload.args.map((a) => JSON.stringify(a)), | ||
params: payload.args.map(serializeActionArgument), | ||
application: payload.spec, | ||
@@ -32,3 +54,3 @@ timestamp: payload.timestamp.toString(), | ||
{ name: "loginTo", type: "string" }, | ||
{ name: "registerSessionKey", type: "string" }, | ||
{ name: "registerSessionAddress", type: "string" }, | ||
{ name: "registerSessionDuration", type: "uint256" }, | ||
@@ -41,8 +63,8 @@ { name: "timestamp", type: "uint256" }, | ||
name: "Canvas", | ||
salt: utils.hexlify(utils.zeroPad(utils.arrayify(payload.from), 32)), | ||
salt: utils.hexlify(utils.zeroPad(utils.arrayify(payload.from), 32)).toLowerCase(), | ||
}; | ||
const sessionValue = { | ||
loginTo: payload.spec, | ||
registerSessionKey: payload.session_public_key, | ||
registerSessionDuration: payload.session_duration.toString(), | ||
registerSessionAddress: payload.address.toLowerCase(), | ||
registerSessionDuration: payload.duration.toString(), | ||
timestamp: payload.timestamp.toString(), | ||
@@ -49,0 +71,0 @@ }; |
{ | ||
"name": "@canvas-js/interfaces", | ||
"version": "0.0.16", | ||
"version": "0.0.17-alpha", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "author": "Canvas Technology Corporation (https://canvas.xyz)", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5284
146