@vela-ventures/aosync-sdk-react 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -91,16 +91,17 @@ export default WalletComponent;
91
91
 
92
92
  The `useWallet` hook provides the following methods and properties:
93
93
 
94
- | Method/Property | Description |
95
- | -------------------------------------------- | ---------------------------------------------- |
96
- | `isConnected` | Boolean indicating if the wallet is connected. |
97
- | `connect()` | Connects to the wallet. |
98
- | `disconnect()` | Disconnects from the wallet. |
99
- | `getAddress()` | Returns the currently active wallet address. |
100
- | `getAllAddresses()` | Returns all wallet addresses. |
101
- | `sendAR(recipient, quantity)` | Sends AR to the specified address. |
102
- | `sign(transaction)` | Signs a transaction using the wallet. |
103
- | `signAOMessage(target, recipient, quantity)` | Signs a custom AO message. |
94
+ | Method/Property | Description |
95
+ | ----------------------------------- | ---------------------------------------------- |
96
+ | `isConnected` | Boolean indicating if the wallet is connected. |
97
+ | `connect()` | Connects to the wallet. |
98
+ | `disconnect()` | Disconnects from the wallet. |
99
+ | `getAddress()` | Returns the currently active wallet address. |
100
+ | `getAllAddresses()` | Returns all wallet addresses. |
101
+ | `sendAR(recipient, quantity)` | Sends AR to the specified address. |
102
+ | `sign(transaction)` | Signs a transaction using the wallet. |
103
+ | `signAOMessage(target, tags, data)` | Signs an ANS-104 Data Item. |
104
+ | `signAODataItem(dataItem)` | Signs an ANS-104 Data Item. |
104
105
 
105
106
  ## License
106
107
 
package/dist/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { DataItem } from "arconnect";
1
2
  import Transaction from "arweave/web/lib/transaction";
2
3
  export interface AOSyncSDKContext {
3
4
  isConnected: boolean;
@@ -6,6 +7,10 @@ export interface AOSyncSDKContext {
6
7
  getAllAddresses: () => Promise<string[]>;
7
8
  getAddress: () => Promise<string | undefined>;
8
9
  sendAR: (recipient: string, quantity: string) => Promise<any>;
9
- signAOMessage: (target: string, recipient: string, quantity: string) => Promise<any>;
10
+ signAOMessage: (target: string, tags: {
11
+ name: string;
12
+ value: string;
13
+ }[], data: string) => Promise<any>;
14
+ signAODataItem: (dataItem: DataItem) => Promise<any>;
10
15
  sign: (transaction: Transaction) => Promise<Transaction>;
11
16
  }
@@ -81,19 +81,38 @@ export function AOSyncProvider({ gatewayConfig = { host: "arweave.net", port: 44
81
81
  throw error;
82
82
  }
83
83
  });
84
- const signAOMessage = (target, recipient, quantity) => __awaiter(this, void 0, void 0, function* () {
84
+ const signAODataItem = (dataItem) => __awaiter(this, void 0, void 0, function* () {
85
+ try {
86
+ const signedDataItem = yield walletRef.current.signDataItem(dataItem);
87
+ const response = yield fetch(muUrl, {
88
+ method: "POST",
89
+ headers: {
90
+ "Content-Type": "application/octet-stream",
91
+ },
92
+ body: signedDataItem,
93
+ });
94
+ if (!response.ok) {
95
+ throw new Error("Network response was not ok");
96
+ }
97
+ return signedDataItem;
98
+ }
99
+ catch (error) {
100
+ console.error("Error signing AO message:", error);
101
+ throw error;
102
+ }
103
+ });
104
+ const signAOMessage = (target, tags, data) => __awaiter(this, void 0, void 0, function* () {
85
105
  try {
86
106
  const dataItem = {
87
- data: "",
107
+ data: data,
88
108
  target,
89
109
  tags: [
90
110
  { name: "Action", value: "Transfer" },
91
- { name: "Recipient", value: recipient },
92
- { name: "Quantity", value: quantity },
93
111
  { name: "SDK", value: "Beacon Wallet" },
94
112
  { name: "Data-Protocol", value: "ao" },
95
113
  { name: "Variant", value: "ao.TN.1" },
96
114
  { name: "Type", value: "Message" },
115
+ ...tags,
97
116
  ],
98
117
  };
99
118
  const signedDataItem = yield walletRef.current.signDataItem(dataItem);
@@ -131,6 +150,7 @@ export function AOSyncProvider({ gatewayConfig = { host: "arweave.net", port: 44
131
150
  getAllAddresses,
132
151
  sendAR,
133
152
  signAOMessage,
153
+ signAODataItem,
134
154
  sign,
135
155
  } }, children));
136
156
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vela-ventures/aosync-sdk-react",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist"