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

feat: node support in codegen server #762

Merged
merged 1 commit into from
Mar 20, 2023
Merged

feat: node support in codegen server #762

merged 1 commit into from
Mar 20, 2023

Conversation

tjjfvi
Copy link
Contributor

@tjjfvi tjjfvi commented Mar 20, 2023

Resolves #719

// package.json
{
  "type": "module",
  "dependencies": {
    "@capi/westend-dev": "http://localhost:4646/frame/dev/westend/@latest/pkg.tar",
    "capi": "file:../capi/target/npm/capi-v0.1.0.tgz"
  }
}
// transfer.ts
import { alice, bob } from "capi";
import { Balances } from "@capi/westend-dev";
import { signature } from "capi/patterns/signature/polkadot";

const result = await Balances
  .transfer({
    value: 12345n,
    dest: bob.address,
  })
  .signed(signature({ sender: alice }))
  .sent()
  .dbgStatus()
  .finalizedEvents()
  .run();

console.log(result);
//          ^? - const result: Event<EventsChain<EventsChain<WestendDev>>>[]
// npx ts-node-esm transfer.ts
ready
{
  inBlock: '0x54fe90dc4c91d1770ecfec14b632a3d41d0348921cbcd058d2d271008e1952fa'
}
{
  finalized: '0x54fe90dc4c91d1770ecfec14b632a3d41d0348921cbcd058d2d271008e1952fa'
}
[
  {
    phase: { type: 'ApplyExtrinsic', value: 2 },
    event: { type: 'Balances', value: [Object] },
    topics: []
  },
  {
    phase: { type: 'ApplyExtrinsic', value: 2 },
    event: { type: 'Balances', value: [Object] },
    topics: []
  },
  {
    phase: { type: 'ApplyExtrinsic', value: 2 },
    event: { type: 'Balances', value: [Object] },
    topics: []
  },
  {
    phase: { type: 'ApplyExtrinsic', value: 2 },
    event: { type: 'TransactionPayment', value: [Object] },
    topics: []
  },
  {
    phase: { type: 'ApplyExtrinsic', value: 2 },
    event: { type: 'System', value: [Object] },
    topics: []
  }
]

Copy link
Contributor

@harrysolovay harrysolovay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tjjfvi tjjfvi added this pull request to the merge queue Mar 20, 2023
@tjjfvi tjjfvi merged commit ff26fd9 into main Mar 20, 2023
@tjjfvi tjjfvi deleted the generate-tar branch March 20, 2023 15:52
@tjjfvi tjjfvi mentioned this pull request Mar 20, 2023
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.

node support on codegen server
2 participants