@canvas-js/interfaces
Advanced tools
Comparing version 0.0.33 to 0.0.34-alpha
@@ -14,7 +14,9 @@ import type { Chain, ChainId } from "./contracts.js"; | ||
timestamp: number; | ||
block?: Block; | ||
chain: Chain; | ||
chainId: ChainId; | ||
blockhash: string | null; | ||
}; | ||
export type ActionPayload = ActionContext & { | ||
call: string; | ||
args: ActionArgument[]; | ||
args: Record<string, ActionArgument>; | ||
}; | ||
@@ -21,0 +23,0 @@ export type Action = { |
@@ -1,2 +0,2 @@ | ||
import type { Block } from "./actions.js"; | ||
import { Chain, ChainId } from "./contracts.js"; | ||
export type SessionPayload = { | ||
@@ -8,3 +8,5 @@ from: string; | ||
duration: number; | ||
block?: Block; | ||
blockhash: string | null; | ||
chain: Chain; | ||
chainId: ChainId; | ||
}; | ||
@@ -11,0 +13,0 @@ export type Session = { |
@@ -33,2 +33,3 @@ import { utils } from "ethers"; | ||
} | ||
const namePattern = /^[a-zA-Z][a-zA-Z0-9]*$/; | ||
export function getActionSignatureData(payload) { | ||
@@ -39,5 +40,14 @@ const domain = { | ||
}; | ||
const keys = Object.keys(payload.args).sort(); | ||
const params = keys.map((key) => { | ||
if (namePattern.test(key)) { | ||
return `${key}: ${serializeActionArgument(payload.args[key])}`; | ||
} | ||
else { | ||
throw new Error("invalid argument name"); | ||
} | ||
}); | ||
const actionValue = { | ||
sendAction: payload.call, | ||
params: payload.args.map(serializeActionArgument), | ||
params: params, | ||
application: payload.spec, | ||
@@ -44,0 +54,0 @@ timestamp: payload.timestamp.toString(), |
{ | ||
"name": "@canvas-js/interfaces", | ||
"version": "0.0.33", | ||
"version": "0.0.34-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
5810
171