Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

feat: smart contract type derivation #153

Merged
merged 2 commits into from
Jul 11, 2022
Merged

feat: smart contract type derivation #153

merged 2 commits into from
Jul 11, 2022

Conversation

harrysolovay
Copy link
Contributor

This PR adjusts type derivation such that we can supply smart contract type metadata. Enables us to start building out a higher-level contracts API.

// Import the contract's metadata
const raw = await Deno.readTextFile("frame_metadata/raw_erc20_metadata.json");

// Normalize that metadata (`normalize` is from `frame_metadata/Contracts.ts`)
const normalized = normalize(raw);

// Create the codec derivation fn
const deriveContractType = DeriveCodec(normalized.V3.types);

// Derive a specific codec
const probablyU128 = deriveContractType(0);

const encoded = probablyU128.encode(101);
const decoded = probablyU128.decode(encoded);

@harrysolovay harrysolovay merged commit b94161a into main Jul 11, 2022
@harrysolovay harrysolovay deleted the contract-support branch July 11, 2022 16:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant