Skip to content

Commit

Permalink
fix(types): remove DataItem from WriteInteractionResult
Browse files Browse the repository at this point in the history
We do not allow L2 interactions for writes on smartweave so we should never return a DataItem
  • Loading branch information
dtfiedler committed May 31, 2024
1 parent 9b4b19f commit eadb1a1
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 43 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@
"arweave": "1.14.4",
"axios": "1.6.0",
"bunyan": "^1.8.15",
"warp-arbundles": "^1.0.4",
"warp-contracts": "1.4.45"
},
"lint-staged": {
Expand Down
6 changes: 3 additions & 3 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { ArconnectSigner, ArweaveSigner } from 'arbundles';
import { DataItem } from 'warp-arbundles';
import { GQLNodeInterface, Transaction } from 'warp-contracts';

import { RemoteContract, WarpContract } from './common/index.js';
Expand Down Expand Up @@ -56,7 +55,7 @@ export type WithSigner<T = NonNullable<unknown>> = {
signer: ContractSigner;
} & T; // TODO: optionally allow JWK in place of signer
export type OptionalSigner<T = NonNullable<unknown>> = {
signer?: ContractSigner;
signer?: ContractSigner | undefined;
} & T;
export type ContractConfiguration<T = NonNullable<unknown>> =
| {
Expand Down Expand Up @@ -288,7 +287,8 @@ export interface ArIOWriteContract {
): Promise<WriteInteractionResult>;
}

export type WriteInteractionResult = Transaction | DataItem;
// we only support L1 smartweave interactions
export type WriteInteractionResult = Transaction;

// Helper type to overwrite properties of A with B
type Overwrite<T, U> = {
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 @@ -230,7 +230,8 @@ export class WarpContract<T>
interactionTxId: writeResult.originalTxId,
});

return writeResult.interactionTx;
// hack - we only support L1 for interactions so they should always be transactions
return writeResult.interactionTx as Transaction;
} catch (error) {
this.logger.error(
`Failed to write contract interaction: ${error.message}`,
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/ant-writable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('ANT Writable', () => {
],
},
);
const tx = await arweave.transactions.get(await res.id);
const tx = await arweave.transactions.get(res.id);
const tags = tx.tags as Tag[];
const customTag = tags.find(
(tag) =>
Expand Down
17 changes: 8 additions & 9 deletions tests/integration/ar-io-writable.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ArweaveSigner } from 'arbundles';
import Transaction, { Tag } from 'arweave/node/lib/transaction.js';
import { Tag } from 'arweave/node/lib/transaction.js';

import { ArIO, ArIOWritable } from '../../src/common/ar-io.js';
import { WarpContract } from '../../src/common/index.js';
Expand Down Expand Up @@ -49,7 +49,7 @@ describe('ArIOWriteable', () => {
autoStake: true,
});
expect(tx.id).toBeDefined();
const verified = await arweave.transactions.verify(tx as Transaction);
const verified = await arweave.transactions.verify(tx);
expect(verified).toBe(true);
});

Expand All @@ -59,7 +59,7 @@ describe('ArIOWriteable', () => {
qty: new IOToken(100).toMIO(),
});
expect(tx.id).toBeDefined();
const verified = await arweave.transactions.verify(tx as Transaction);
const verified = await arweave.transactions.verify(tx);
expect(verified).toBe(true);
const gateway = await arIO.getGateway({ address: gatewayAddress });
expect(gateway?.delegates[interactingAddress]).toEqual({
Expand All @@ -75,7 +75,7 @@ describe('ArIOWriteable', () => {
qty: new IOToken(100).toMIO(),
});
expect(tx.id).toBeDefined();
const verified = await arweave.transactions.verify(tx as Transaction);
const verified = await arweave.transactions.verify(tx);
expect(verified).toBe(true);
const gateway = await arIO.getGateway({ address: gatewayAddress });
expect(gateway?.delegates[interactingAddress]).toEqual({
Expand All @@ -101,7 +101,7 @@ describe('ArIOWriteable', () => {
qty: new IOToken(10).toMIO(),
});
expect(tx.id).toBeDefined();
const verified = await arweave.transactions.verify(tx as Transaction);
const verified = await arweave.transactions.verify(tx);
expect(verified).toBe(true);
const targetBalance = await arIO.getBalance({ address: target });
expect(targetBalance).toEqual(new IOToken(10).toMIO().valueOf());
Expand All @@ -125,7 +125,7 @@ describe('ArIOWriteable', () => {
years,
});
expect(tx.id).toBeDefined();
const verified = await arweave.transactions.verify(tx as Transaction);
const verified = await arweave.transactions.verify(tx);
expect(verified).toBe(true);
const record = (await arIO.getArNSRecord({ domain })) as ArNSLeaseData;
expect(record?.endTimestamp).toBe(
Expand All @@ -151,8 +151,7 @@ describe('ArIOWriteable', () => {
},
);

const tx = await arweave.transactions.get(await res.id);
console.dir(tx, { depth: null });
const tx = await arweave.transactions.get(res.id);
const tags = tx.tags as Tag[];
const arIOFunctionTag = tags.find(
(tag) =>
Expand All @@ -164,7 +163,7 @@ describe('ArIOWriteable', () => {
);

expect(res.id).toBeDefined();
const verified = await arweave.transactions.verify(res as Transaction);
const verified = await arweave.transactions.verify(res);
expect(verified).toBe(true);
const record = await arIO.getArNSRecord({ domain });
expect(record?.undernames).toBe(11);
Expand Down
31 changes: 3 additions & 28 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9427,7 +9427,7 @@ string-length@^4.0.1:
char-regex "^1.0.2"
strip-ansi "^6.0.0"

"string-width-cjs@npm:string-width@^4.2.0":
"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand All @@ -9445,15 +9445,6 @@ string-width@^1.0.1:
is-fullwidth-code-point "^1.0.0"
strip-ansi "^3.0.0"

"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^5.0.1, string-width@^5.1.2:
version "5.1.2"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794"
Expand Down Expand Up @@ -9514,7 +9505,7 @@ string_decoder@~1.1.1:
dependencies:
safe-buffer "~5.1.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand All @@ -9528,13 +9519,6 @@ strip-ansi@^3.0.0, strip-ansi@^3.0.1:
dependencies:
ansi-regex "^2.0.0"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^7.0.1, strip-ansi@^7.1.0:
version "7.1.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
Expand Down Expand Up @@ -10350,16 +10334,7 @@ wordwrap@^1.0.0:
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
integrity sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand Down

0 comments on commit eadb1a1

Please sign in to comment.