Skip to content

Commit

Permalink
Sign data item with signdataitem in browser
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-toth committed Feb 23, 2024
1 parent 0015f83 commit 8582eb2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
18 changes: 4 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"@types/uuid": "^9.0.6",
"@typescript-eslint/eslint-plugin": "^6.4.1",
"@typescript-eslint/parser": "^6.4.1",
"arconnect": "1.0.3",
"arlocal": "^1.1.62",
"chai": "^4.3.8",
"chai-as-promised": "^7.1.1",
Expand All @@ -84,5 +85,8 @@
"uuid": "^9.0.1",
"warp-contracts": "1.4.36",
"warp-contracts-plugin-deploy": "1.0.13"
},
"overrides": {
"arconnect": "1.0.3"
}
}
6 changes: 6 additions & 0 deletions src/common/data-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ export default class DataItemFactory {
data: string | Uint8Array,
tags?: Tag[]
): Promise<DataItem> {
if (this.signer instanceof InjectedArweaveSigner) {
const signed = await window.arweaveWallet.signDataItem({ data, tags })

return new DataItem(Buffer.from(signed))
}

const dataItem = createData(data, this.signer, { tags })
await dataItem.sign(this.signer)

Expand Down

0 comments on commit 8582eb2

Please sign in to comment.