@vela-ventures/aosync-sdk-react 1.0.6 → 1.0.8

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
@@ -35,6 +35,7 @@ const App = () => {
35
35
  port: 443,
36
36
  protocol: "https",
37
37
  }}
38
+ appInfo={{ name: "App name" }}
38
39
  muUrl="https://mu.ao-testnet.xyz"
39
40
  >
40
41
  <YourApp />
@@ -91,16 +92,17 @@ export default WalletComponent;
91
92
 
92
93
  The `useWallet` hook provides the following methods and properties:
93
94
 
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. |
95
+ | Method/Property | Description |
96
+ | ----------------------------------- | ---------------------------------------------- |
97
+ | `isConnected` | Boolean indicating if the wallet is connected. |
98
+ | `connect()` | Connects to the wallet. |
99
+ | `disconnect()` | Disconnects from the wallet. |
100
+ | `getAddress()` | Returns the currently active wallet address. |
101
+ | `getAllAddresses()` | Returns all wallet addresses. |
102
+ | `sendAR(recipient, quantity)` | Sends AR to the specified address. |
103
+ | `sign(transaction)` | Signs a transaction using the wallet. |
104
+ | `signAOMessage(target, tags, data)` | Signs an ANS-104 Data Item. |
105
+ | `signAODataItem(dataItem)` | Signs an ANS-104 Data Item. |
104
106
 
105
107
  ## License
106
108
 
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;
@@ -10,5 +11,6 @@ export interface AOSyncSDKContext {
10
11
  name: string;
11
12
  value: string;
12
13
  }[], data: string) => Promise<any>;
14
+ signAODataItem: (dataItem: DataItem) => Promise<any>;
13
15
  sign: (transaction: Transaction) => Promise<Transaction>;
14
16
  }
@@ -1,10 +1,11 @@
1
1
  export { useWallet } from "./useWallet";
2
2
  import React, { PropsWithChildren } from "react";
3
- import { GatewayConfig } from "arconnect";
3
+ import { AppInfo, GatewayConfig } from "arconnect";
4
4
  import { AOSyncSDKContext } from "./types";
5
5
  export declare const AOSyncContext: React.Context<AOSyncSDKContext | undefined>;
6
6
  interface Props extends PropsWithChildren {
7
7
  gatewayConfig: GatewayConfig;
8
8
  muUrl: string;
9
+ appInfo?: AppInfo;
9
10
  }
10
- export declare function AOSyncProvider({ gatewayConfig, muUrl, children, }: Props): React.JSX.Element;
11
+ export declare function AOSyncProvider({ gatewayConfig, muUrl, children, appInfo, }: Props): React.JSX.Element;
@@ -12,7 +12,7 @@ import React, { useEffect, useRef, useState, createContext, } from "react";
12
12
  import Arweave from "arweave";
13
13
  import WalletClient from "@vela-ventures/ao-sync-sdk";
14
14
  export const AOSyncContext = createContext(undefined);
15
- export function AOSyncProvider({ gatewayConfig = { host: "arweave.net", port: 443, protocol: "https" }, muUrl = "https://mu.ao-testnet.xyz", children, }) {
15
+ export function AOSyncProvider({ gatewayConfig = { host: "arweave.net", port: 443, protocol: "https" }, muUrl = "https://mu.ao-testnet.xyz", children, appInfo, }) {
16
16
  const [isConnected, setIsConnected] = useState(false);
17
17
  const walletRef = useRef(new WalletClient());
18
18
  useEffect(() => {
@@ -31,6 +31,7 @@ export function AOSyncProvider({ gatewayConfig = { host: "arweave.net", port: 44
31
31
  try {
32
32
  yield walletRef.current.connect({
33
33
  gateway: gatewayConfig,
34
+ appInfo,
34
35
  });
35
36
  }
36
37
  catch (error) {
@@ -81,6 +82,26 @@ export function AOSyncProvider({ gatewayConfig = { host: "arweave.net", port: 44
81
82
  throw error;
82
83
  }
83
84
  });
85
+ const signAODataItem = (dataItem) => __awaiter(this, void 0, void 0, function* () {
86
+ try {
87
+ const signedDataItem = yield walletRef.current.signDataItem(dataItem);
88
+ const response = yield fetch(muUrl, {
89
+ method: "POST",
90
+ headers: {
91
+ "Content-Type": "application/octet-stream",
92
+ },
93
+ body: signedDataItem,
94
+ });
95
+ if (!response.ok) {
96
+ throw new Error("Network response was not ok");
97
+ }
98
+ return signedDataItem;
99
+ }
100
+ catch (error) {
101
+ console.error("Error signing AO message:", error);
102
+ throw error;
103
+ }
104
+ });
84
105
  const signAOMessage = (target, tags, data) => __awaiter(this, void 0, void 0, function* () {
85
106
  try {
86
107
  const dataItem = {
@@ -130,6 +151,7 @@ export function AOSyncProvider({ gatewayConfig = { host: "arweave.net", port: 44
130
151
  getAllAddresses,
131
152
  sendAR,
132
153
  signAOMessage,
154
+ signAODataItem,
133
155
  sign,
134
156
  } }, children));
135
157
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vela-ventures/aosync-sdk-react",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist"