-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot Build CLKey from Contract Hash #327
Comments
Just looking how casper-js-sdk/src/lib/CLValue/Key.ts Lines 49 to 57 in e217c4b
The idea is that regular byte array is prefixed with variant byte. So as a workaround we can do it manually: import { KeyVariant, CLByteArray, CLValueBuilder } from "casper-js-sdk";
import { concat } from '@ethersproject/bytes';
const contractHash = "cb781f66f78a398bf1709c4dac40b3cca17106824ea88ca9daa5b822421c9b57";
const clContractHash = new CLByteArray(
concat([
Uint8Array.from([KeyVariant.Hash]),
Uint8Array.from(Buffer.from(contractHash, 'hex'))
])
);
const key = CLValueBuilder.key(clContractHash); It works, but |
Nice solution. In my case, adding const clContractHash = new CLByteArray(Uint8Array.from(Buffer.from(contractHash, "hex")));
const key = CLValueBuilder.key(clContractHash); I had previously tried this, but was using import { decodeBase16, CLByteArray, CLValueBuilder } from "casper-js-sdk";
const contractHash = "cb781f66f78a398bf1709c4dac40b3cca17106824ea88ca9daa5b822421c9b57";
const clContractHash = new CLByteArray(decodeBase16(contractHash));
const key = CLValueBuilder.key(clContractHash); Should still implement a |
hey guys, yeah we will add |
Using the casper-client, it is possible to give any hash value the type
key
, but the Casper JS SDK lacks the ability to build aCLKey
object from any given hash.For example, on line 7 in this shell script, a
key
argument is defined with the value "hash-b62481085812c4f56027f5fb7f3e5e2f087b14190da8762fb88889e4945178be".This works properly. Here is a successful deploy as an example (expand the raw data and look under the first argument
contract_hash
).Using the Casper JS SDK, however, it appears this cannot be done.
Traditionally, building a
CLKey
object is done by callingCLValueBuilder.key()
, which accepts a parameter of typeCLKeyParameters
, which is any of the following types:Reference: CLKey, CLValueBuilder.key, CLKeyParameters.
Converting the contract hash string above into any of these four types, and then into a
CLKey
usingCLValueBuilder.key(CLKeyParameters)
yields different errors, from the inability to unpack the deploy in the Casper Wallet to empty arguments when deployed.Here is my attempted implementation.
My proposed solution is creating a new class
CLContractHash
and conforming it toCLKeyParameters
.The text was updated successfully, but these errors were encountered: