permaweb / ao

The ao component and tools Monorepo - 🐰 🕳️ 👈
https://cookbook_ao.arweave.dev
Other
189 stars 61 forks source link

feat(sdk): for `Message` and `Spawn` add the option to send `data` value #285

Closed twilson63 closed 10 months ago

twilson63 commented 10 months ago

As a developer, I would like to send a message or spawn a process with some data

import { createDataItemSigner, message } from "@permaweb/ao-sdk";

const messageId = await message({
  process,
  signer: createDataItemSigner(wallet),
  anchor,
  tags,
  data
});

or

import { createDataItemSigner, spawn } from "@permaweb/ao-sdk";

const processId = await spawn({
  module,
  scheduler,
  signer: createDataItemSigner(wallet),
  tags,
  data
});

NOTE: 🤔

It may be worth considering changing the ao-sdk API to be similar to the aos API

import { createDataItemSigner, connect } from "@permaweb/ao-sdk";
const signer = createDataItemSigner(globalThis.arweave.wallet)
const { send, spawn } = connect(signer)
send({
  Target = "",
  Tags = { Action: "Eval" },
  Data = "1 + 1"
})
spawn(module, {
  Tags = { Scheduler: "ao-sched" },
  Data = ""
})
twilson63 commented 10 months ago

Looks like data is already supported, just need to update readme.