Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: release v1.0.3 #62

Merged
merged 6 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ar.io/sdk",
"version": "1.0.2",
"version": "1.0.3-alpha.1",
"repository": {
"type": "git",
"url": "git+https://github.com/ar-io/ar-io-sdk.git"
Expand Down
3 changes: 2 additions & 1 deletion src/common/contracts/warp-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { FailedRequestError, WriteInteractionError } from '../error.js';
import { DefaultLogger } from '../logger.js';
import { defaultWarp } from '../warp.js';

LoggerFactory.INST.logLevel('fatal');
LoggerFactory.INST.logLevel('error');

export class WarpContract<T>
implements BaseContract<T>, ReadContract, WriteContract
Expand Down Expand Up @@ -87,6 +87,7 @@ export class WarpContract<T>
}
const warpSigner = new Signature(this.warp, {
signer: async (tx: Transaction) => {
tx.setOwner(toB64Url(signer.publicKey));
const dataToSign = await tx.getSignatureData();
const signatureUint8Array = await signer.sign(dataToSign);
const signatureBuffer = Buffer.from(signatureUint8Array);
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@

// AUTOMATICALLY GENERATED FILE - DO NOT TOUCH

export const version = '1.0.2';
export const version = '1.0.3-alpha.1';
82 changes: 60 additions & 22 deletions tests/integration/ant-writable.test.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
import { ArweaveSigner } from 'arbundles';
import Transaction from 'arweave/node/lib/transaction.js';

import { ANT, ANTWritable, WarpContract } from '../../src/common/index.js';
import { DefaultLogger } from '../../src/common/logger.js';
import { ANTState } from '../../src/contract-state.js';
import { localCacheUrl, warp } from '../constants.js';

const writeTestCases = Object.entries({
setController: { controller: ''.padEnd(43, 'a') },
removeController: { controller: ''.padEnd(43, 'a') },
setName: { name: 'test' },
setTicker: { ticker: 'test' },
setRecord: {
subDomain: 'test',
transactionId: ''.padEnd(43, 'a'),
ttlSeconds: 900,
},
removeRecord: { subDomain: 'test' },
transfer: { target: ''.padEnd(43, 'a') },
});
import { arweave, localCacheUrl, warp } from '../constants.js';

describe('ANT Writable', () => {
let signer: ArweaveSigner;
Expand All @@ -38,11 +25,62 @@ describe('ANT Writable', () => {
});
});

it.each(writeTestCases)(
'should execute write operation: %s',
async (method, inputs) => {
const result = await antWritable[method](inputs);
expect(result).toBeDefined();
},
);
it('should successfully set controller', async () => {
const tx = await antWritable.setController({
controller: ''.padEnd(43, 'a'),
});
expect(tx.id).toBeDefined();
const verified = await arweave.transactions.verify(tx as Transaction);
expect(verified).toBe(true);
});

it('should successfully remove controller', async () => {
const tx = await antWritable.removeController({
controller: ''.padEnd(43, 'a'),
});
expect(tx.id).toBeDefined();
const verified = await arweave.transactions.verify(tx as Transaction);
expect(verified).toBe(true);
});

it('should successfully set name', async () => {
const tx = await antWritable.setName({ name: 'test' });
expect(tx.id).toBeDefined();
const verified = await arweave.transactions.verify(tx as Transaction);
expect(verified).toBe(true);
});

it('should successfully set ticker', async () => {
const tx = await antWritable.setTicker({ ticker: 'test' });
expect(tx.id).toBeDefined();
const verified = await arweave.transactions.verify(tx as Transaction);
expect(verified).toBe(true);
});

it('should successfully set record', async () => {
const tx = await antWritable.setRecord({
subDomain: 'test',
transactionId: ''.padEnd(43, 'a'),
ttlSeconds: 900,
});
expect(tx.id).toBeDefined();
const verified = await arweave.transactions.verify(tx as Transaction);
expect(verified).toBe(true);
});

it('should successfully remove record', async () => {
const tx = await antWritable.removeRecord({ subDomain: 'test' });
expect(tx.id).toBeDefined();
const verified = await arweave.transactions.verify(tx as Transaction);
expect(verified).toBe(true);
});

it('should successfully transfer tokens to another address', async () => {
const tx = await antWritable.transfer({
target: ''.padEnd(43, 'a'),
});
expect(tx.id).toBeDefined();
const verified = await arweave.transactions.verify(tx as Transaction);
expect(verified).toBe(true);
});
});
27 changes: 18 additions & 9 deletions tests/integration/ar-io-writable.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { ArweaveSigner } from 'arbundles/node';
import Transaction from 'arweave/node/lib/transaction.js';

import { ArIO, ArIOWritable } from '../../src/common/ar-io.js';
import { WarpContract } from '../../src/common/index.js';
import { DefaultLogger } from '../../src/common/logger.js';
import { ArIOState } from '../../src/contract-state.js';
import { gatewayAddress, localCacheUrl, warp } from '../constants.js';
import { arweave, gatewayAddress, localCacheUrl, warp } from '../constants.js';

describe('ArIOWriteable', () => {
let signer: ArweaveSigner;
Expand All @@ -26,7 +27,7 @@ describe('ArIOWriteable', () => {
});

it('should successfully join network', async () => {
const { id: interactionTxId } = await arIO.joinNetwork({
const tx = await arIO.joinNetwork({
fqdn: 'example.com',
label: 'example',
protocol: 'https',
Expand All @@ -39,32 +40,40 @@ describe('ArIOWriteable', () => {
minDelegatedStake: 100,
autoStake: true,
});
expect(interactionTxId).toBeDefined();
expect(tx.id).toBeDefined();
const verified = await arweave.transactions.verify(tx as Transaction);
expect(verified).toBe(true);
});

it('should successfully increase delegate stake', async () => {
const { id: interactionTxId } = await arIO.increaseDelegateStake({
const tx = await arIO.increaseDelegateStake({
target: gatewayAddress,
qty: 101,
});
expect(interactionTxId).toBeDefined();
expect(tx.id).toBeDefined();
const verified = await arweave.transactions.verify(tx as Transaction);
expect(verified).toBe(true);
});

it('should successfully decrease delegate stake', async () => {
const { id: interactionTxId } = await arIO.decreaseDelegateStake({
const tx = await arIO.decreaseDelegateStake({
target: gatewayAddress,
qty: 101,
});
expect(interactionTxId).toBeDefined();
expect(tx.id).toBeDefined();
const verified = await arweave.transactions.verify(tx as Transaction);
expect(verified).toBe(true);
});

it('should successfully transfer tokens to another address', async () => {
const target = ''.padEnd(43, 'f');
const qty = 101;
const { id: interactionTxId } = await arIO.transfer({
const tx = await arIO.transfer({
target,
qty,
});
expect(interactionTxId).toBeDefined();
expect(tx.id).toBeDefined();
const verified = await arweave.transactions.verify(tx as Transaction);
expect(verified).toBe(true);
});
});
Loading