Skip to content

Commit

Permalink
Merge pull request #349 from ar-io/use-undeprecated-arconnect-method
Browse files Browse the repository at this point in the history
fix(arconnect): use signDataItem method, signature is deprecated
  • Loading branch information
fedellen authored Jan 17, 2025
2 parents f60d5cf + 3e1948a commit 6f9fb0a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/utils/ao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { createData } from '@dha-team/arbundles';
import { ArconnectSigner, DataItem, createData } from '@dha-team/arbundles';
import { connect, createDataItemSigner } from '@permaweb/aoconnect';
import Arweave from 'arweave';
import { z } from 'zod';
Expand Down Expand Up @@ -237,6 +237,21 @@ export function createAoSigner(signer: ContractSigner): AoSigner {
) {
await signer.setPublicKey();
}
if (signer instanceof ArconnectSigner) {
// Sign using Arconnect signDataItem API
const signedDataItem = await signer['signer'].signDataItem({
data,
tags,
target,
anchor,
});
const dataItem = new DataItem(Buffer.from(signedDataItem));
return {
id: await dataItem.id,
raw: await dataItem.getRaw(),
};
}

const dataItem = createData(data, signer, { tags, target, anchor });
const signedData = dataItem.sign(signer).then(async () => ({
id: await dataItem.id,
Expand Down

0 comments on commit 6f9fb0a

Please sign in to comment.