Skip to content

Commit e257724

Browse files
authored
test: update contracts to test the latest beta version (#594)
1 parent 5f241e0 commit e257724

File tree

15 files changed

+116
-82
lines changed

15 files changed

+116
-82
lines changed

cypress/e2e/contracts/erc20.spec.ts

Lines changed: 12 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ describe('ERC20 Contract ', () => {
2323
});
2424

2525
it('contract file uploads', () => {
26-
// TODO: In the contract, replaced Address with H160. Fix https://github.com/use-ink/contracts-ui/issues/582
2726
assertUpload('erc20.contract');
2827
});
2928

@@ -54,67 +53,36 @@ describe('ERC20 Contract ', () => {
5453

5554
it(`transfers ${transferValue} Units to another account`, () => {
5655
selectMessage('transfer', 3);
57-
cy.get('.form-field.to')
58-
.find("input[type='text']")
59-
.clear()
60-
.type('0x60afa252b554aabc4b3253ca2be60dc1d536ec10')
61-
.should('have.value', '0x60afa252b554aabc4b3253ca2be60dc1d536ec10');
62-
cy.get('.form-field.value').find('input[type="number"]').type(`${transferValue}`);
56+
cy.get('.form-field.to').find('.dropdown').click().find('.dropdown__option').eq(3).click();
57+
cy.get('.form-field.value').find('input[type="number"]').eq(0).type(`${transferValue}`);
6358
assertCall();
6459
selectMessage('balanceOf', 1);
60+
console.log(initialSupply - transferValue);
61+
cy.get('.form-field.owner').find('.dropdown').click().find('.dropdown__option').eq(0).click();
6562

66-
cy.get('.form-field.owner')
67-
.find("input[type='text']")
68-
.clear()
69-
.type('0x9621dde636de098b43efb0fa9b61facfe328f99d')
70-
.should('have.value', '0x9621dde636de098b43efb0fa9b61facfe328f99d');
7163
assertReturnValue('balanceOf', `${initialSupply - transferValue}`);
7264
});
7365

7466
it(`successfully approves allowance`, () => {
7567
selectMessage('approve', 4);
76-
cy.get('.form-field.spender')
77-
.find("input[type='text']")
78-
.clear()
79-
.type('0x41dccbd49b26c50d34355ed86ff0fa9e489d1e01')
80-
.should('have.value', '0x41dccbd49b26c50d34355ed86ff0fa9e489d1e01');
81-
cy.get('.form-field.value').find('input[type="number"]').type(`${allowance}`);
68+
cy.get('.form-field.spender').find('.dropdown').click().find('.dropdown__option').eq(2).click();
69+
cy.get('.form-field.value').find('input[type="number"]').eq(0).type(`${allowance}`);
8270
assertCall();
8371
selectMessage('allowance', 2);
84-
cy.get('.form-field.owner')
85-
.find("input[type='text']")
86-
.clear()
87-
.type('0x9621dde636de098b43efb0fa9b61facfe328f99d')
88-
.should('have.value', '0x9621dde636de098b43efb0fa9b61facfe328f99d');
89-
cy.get('.form-field.spender')
90-
.find("input[type='text']")
91-
.clear()
92-
.type('0x41dccbd49b26c50d34355ed86ff0fa9e489d1e01')
93-
.should('have.value', '0x41dccbd49b26c50d34355ed86ff0fa9e489d1e01');
72+
cy.get('.form-field.owner').find('.dropdown').click().find('.dropdown__option').eq(0).click();
73+
cy.get('.form-field.spender').find('.dropdown').click().find('.dropdown__option').eq(2).click();
9474
assertReturnValue('allowance', `${allowance}`);
9575
});
9676

9777
it(`transfers ${transferValue} on behalf of alice`, () => {
9878
cy.get('.form-field.caller').click().find('.dropdown__option').eq(2).click();
9979
selectMessage('transferFrom', 5);
100-
cy.get('.form-field.from')
101-
.find("input[type='text']")
102-
.clear()
103-
.type('0x9621dde636de098b43efb0fa9b61facfe328f99d')
104-
.should('have.value', '0x9621dde636de098b43efb0fa9b61facfe328f99d');
105-
cy.get('.form-field.to')
106-
.find("input[type='text']")
107-
.clear()
108-
.type('0x41dccbd49b26c50d34355ed86ff0fa9e489d1e01')
109-
.should('have.value', '0x41dccbd49b26c50d34355ed86ff0fa9e489d1e01');
110-
cy.get('.form-field.value').find('input[type="number"]').type(`${transferValue}`);
80+
cy.get('.form-field.from').find('.dropdown').click().find('.dropdown__option').eq(0).click();
81+
cy.get('.form-field.to').find('.dropdown').click().find('.dropdown__option').eq(2).click();
82+
cy.get('.form-field.value').find('input[type="number"]').eq(0).type(`${transferValue}`);
11183
assertCall();
11284
selectMessage('balanceOf', 1);
113-
cy.get('.form-field.owner')
114-
.find("input[type='text']")
115-
.clear()
116-
.type('0x41dccbd49b26c50d34355ed86ff0fa9e489d1e01')
117-
.should('have.value', '0x41dccbd49b26c50d34355ed86ff0fa9e489d1e01');
85+
cy.get('.form-field.owner').find('.dropdown').click().find('.dropdown__option').eq(2).click();
11886
assertReturnValue('balanceOf', `${transferValue}`);
11987
});
12088
});

cypress/e2e/contracts/mother.spec.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
assertMoveToStep3,
99
assertContractRedirect,
1010
assertInstantiate,
11+
selectAccount,
1112
} from '../../support/util';
1213

1314
describe('Mother Contract ', () => {
@@ -76,12 +77,9 @@ describe('Mother Contract ', () => {
7677
.within(() => {
7778
cy.get('[data-cy="switch-button"]').click();
7879
cy.contains('0: H160').should('be.visible');
79-
cy.get("input[type='text']")
80-
.clear()
81-
.type('0x41dccbd49b26c50d34355ed86ff0fa9e489d1e01')
82-
.should('have.value', '0x41dccbd49b26c50d34355ed86ff0fa9e489d1e01');
8380
cy.contains('1: u128').should('be.visible');
8481
cy.get("input[type='number']").should('have.lengthOf', 1).type('99999');
82+
selectAccount('bob', 2);
8583
});
8684
});
8785
});

cypress/fixtures/erc20.contract

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

cypress/fixtures/flipper.contract

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"source":{"hash":"0x446432cef50701445b70a99fe5f732beb639076f434c7818b53a827ea58e8886","language":"ink! 6.0.0-alpha.3","compiler":"rustc 1.89.0","contract_binary":"0x50564d0000ef06000000000000010600c00040a000045505000000000e00000019000000240000002f00000063616c6c5f646174615f636f70796765745f73746f726167657365616c5f72657475726e7365745f73746f7261676576616c75655f7472616e7366657272656405110283870463616c6c84e2066465706c6f7906866c11028593ad01b902ba02bb02e202070368039803b60319046704d804f3042a0544057a058b056472531910bb008d2c84c407c842056487642aae52107c7b95770178ab95aa01ac5af6c8480cc949068469f884cb07c8950a510b19017b197b16087b1c1033054911189ab608951918846701d4b90351070e8217107c77783733050101846702510714821710c857077f77c8530979979555020184670497b603510711821710c857078177c853037a37018219188d67847038c9b808958308642701c8470c95cb08c84308d06905aeab198289953308cf0908d458087bc895770828e1642a28693306821b1084b70449111851070c81877a17183306040184b702510717c84607c837077f77951818d4680879879566020184b701510714c86404c843037c37951818d46808788701821718cf0707d457077bc78216088219c89b088469072809c89b0884690701c8a909ae9a107c8795880178a795aa01ac9af66427821030821528821620951138320064c764cbaea5d282789577087b58955508aea5c528f39511f07b1008648a78170795180733090164a733002228d0039511f07b100848110495180433090433002228bb039511a87b10507b15487b16403305000002641633070000023300020a0401805210805814805918805a1c8053805c04805708805b0c49112049112849113049113897aa2097882097bb2097cc20d4a909d42808951220d4b707d43c0a7b1a7b17087b18107b1918330704017c68017c69027c6a037c6b97880897991097aa18d4b8087c6b047c6c05d4a9097c6a067c650797cc08d4cb0b97aa10975518d45a0a956608d49808d4ba0a97aa20d4a8087b289522089577ff5207b4951920330705330805019588ff51080f829a959908510af5330704018210508215488216409511583200827808510814827a7ca9958bff95aa017b7a7b7b0828053309019597ff8e77957a01939a330702db8a0732003300089511f87b1033080000021f0300000233090233070a02000000009511c87b10307b15287b16207b1733070000027b1708491110004049111895170850100a9dfe821710821518ac574b821608c95707c856087b18087b1710491118951808821750100c5ffe821810821718ac7826821a08975920989920977720987b20330764680a03821030821528821620951138320000838852080f330a330901330b00000228163308000002330a013b0a000002c8a80b330902019511f87b10330800000278ba0a020082191052090b33080133070a0200835501ac590400330800000233070a02009511c87b10307b15287b1620501010fcfd8477ff00521705b000330933050000023308004033070000023300120a018057977930977828847aff0098993898883895abd1987718510b2095aa9d520a799599c652097395885bff52086c9577af5207663306281a95997aff52095b9588a5520855957727ff52074e330601017b1508491110004049111895170850101466fd821710821518ac572d7b16821808c957069759207a1608c88505989920951b083307645a0a0101801808ac86098377510711000033080133070133000428defe7b15087b181095170850101611fe8218108477ff009579fe8899018e88d49808977a081407010000000d000000da8a078478015208c084780003958800fe5108b58477000182185108308e773300069511d87b10207b15183308000002330500401e030000027b187b150849111001641833000e2894fc887701501018e9fd330833073300042855fe9511d87b10207b15187b161050101aa1fc8477ff0052170547330933050000023308004095560433070000020a0139070000027b16491108fc3f52479bae9d5e16641750101c4efd8477ff005217021133080133070133000428f9fd0050101e7dfd285bfd9511e87b10107b15087b166475827710c89706ac7630825a08ac6a2a825ac8a7073300209511c87b10307b15287b16202889fa7b56108210108215088216951118320000821008951110320085924a29499244494992a432494a9924294d499a242949a94a92924952522649499394929249292949aa949292929424499224098534494a9224499224294926294992244992244949924c4a32494a2a2935a5a4a410529f2485842424499224852449922a495a4a28242453a8496a32d42409110a117249244992249254248964421292942449aa49394992844452124092884429494284122509952449882844c2a110284424c99024952429499224294d0200","build_info":{"rust_toolchain":"stable-aarch64-apple-darwin","cargo_contract_version":"6.0.0-alpha.3","build_mode":"Release"}},"contract":{"name":"flipper","version":"6.0.0-alpha.3","authors":["Use Ink <[email protected]>"]},"image":null,"version":6,"types":[{"id":0,"type":{"def":{"primitive":"bool"}}},{"id":1,"type":{"path":["flipper","flipper","Flipper"],"def":{"composite":{"fields":[{"name":"value","type":0,"typeName":"<bool as::ink::storage::traits::AutoStorableHint<::ink::storage\n::traits::ManualKey<2054318728u32, ()>,>>::Type"}]}}}},{"id":2,"type":{"path":["Result"],"params":[{"name":"T","type":3},{"name":"E","type":4}],"def":{"variant":{"variants":[{"name":"Ok","fields":[{"type":3}],"index":0},{"name":"Err","fields":[{"type":4}],"index":1}]}}}},{"id":3,"type":{"def":{"tuple":[]}}},{"id":4,"type":{"path":["ink_primitives","LangError"],"def":{"variant":{"variants":[{"name":"CouldNotReadInput","index":1}]}}}},{"id":5,"type":{"path":["Result"],"params":[{"name":"T","type":0},{"name":"E","type":4}],"def":{"variant":{"variants":[{"name":"Ok","fields":[{"type":0}],"index":0},{"name":"Err","fields":[{"type":4}],"index":1}]}}}},{"id":6,"type":{"path":["ink_primitives","types","AccountId"],"def":{"composite":{"fields":[{"type":7,"typeName":"[u8; 32]"}]}}}},{"id":7,"type":{"def":{"array":{"len":32,"type":8}}}},{"id":8,"type":{"def":{"primitive":"u8"}}},{"id":9,"type":{"def":{"primitive":"u128"}}},{"id":10,"type":{"path":["ink_primitives","types","Hash"],"def":{"composite":{"fields":[{"type":7,"typeName":"[u8; 32]"}]}}}},{"id":11,"type":{"def":{"primitive":"u64"}}},{"id":12,"type":{"def":{"primitive":"u32"}}}],"storage":{"root":{"root_key":"0x00000000","layout":{"struct":{"name":"Flipper","fields":[{"name":"value","layout":{"leaf":{"key":"0x00000000","ty":0}}}]}},"ty":1}},"spec":{"constructors":[{"label":"new","selector":"0x9bae9d5e","payable":false,"args":[{"label":"init_value","type":{"type":0,"displayName":["bool"]}}],"returnType":{"type":2,"displayName":["ink_primitives","ConstructorResult"]},"docs":["Creates a new flipper smart contract initialized with the given value."],"default":false}],"messages":[{"label":"flip","selector":"0x633aa551","mutates":true,"payable":false,"args":[],"returnType":{"type":2,"displayName":["ink","MessageResult"]},"docs":[" Flips the current value of the Flipper's boolean."],"default":false},{"label":"get","selector":"0x2f865bd9","mutates":false,"payable":false,"args":[],"returnType":{"type":5,"displayName":["ink","MessageResult"]},"docs":[" Returns the current value of the Flipper's boolean."],"default":false}],"events":[],"docs":[],"lang_error":{"type":4,"displayName":["ink","LangError"]},"environment":{"accountId":{"type":6,"displayName":["AccountId"]},"balance":{"type":9,"displayName":["Balance"]},"hash":{"type":10,"displayName":["Hash"]},"timestamp":{"type":11,"displayName":["Timestamp"]},"blockNumber":{"type":12,"displayName":["BlockNumber"]},"nativeToEthRatio":100000000,"staticBufferSize":16384}}}
1+
{"source":{"hash":"0x47be121f2e329c1a73173b0f57fe04cfa7778e4f216ab57bf7c023b3568ba7b3","language":"ink! 6.0.0-beta","compiler":"rustc 1.90.0","contract_binary":"0x50564d0000e606000000000000010600c00040a000045505000000000e00000019000000240000002f00000063616c6c5f646174615f636f70796765745f73746f726167657365616c5f72657475726e7365745f73746f7261676576616c75655f7472616e7366657272656405110281610463616c6c82bc066465706c6f790686631002858d7201f3014102b202cc0203031d033e0355047904c0041f0530056505660585056472531910bb008d2c84c407c842056487642aae52107c7b95770178ab95aa01ac5af6c8480cc949068469f884cb07c8950a510b19017b197b16087b1c1033054911189ab608951918846701d4b90351070e8217107c77783733050101846702510714821710c857077f77c8530979979555020184670497b603510711821710c857078177c853037a37018219188d67847038c9b808958308642701c8470c95cb08c84308d06905aeab198289953308cf0908d458087bc895770828e1642a28693306821b1084b70449111851070c81877a17183306040184b702510717c84607c837077f77951818d4680879879566020184b701510714c86404c843037c37951818d46808788701821718cf0707d457077bc78216088219c89b088469072809c89b0884690701c8a909ae9a107c8795880178a795aa01ac9af66427821030821528821620951138320064c764cbaea5d282789577087b58955508aea5c528f39511c87b10307b15287b1620501002b3018477ff00521705b000330933050000023308004033070000020a013807000002977930977828847aff0098993898883895abd1987718510b2095aa9d520a799599c652097395885bff52086c9577af5207663306281a95997aff52095b9588a5520855957727ff52074e330601017b15084911100040491118951708501004d302821710821518ac572d7b16821808c957069759207a1608c88505989920951b083307645a0a0101801808ac86098377510711000033080133070133001a2801037b15087b1810951708501006c8018218108477ff009579fe8899018e88d49808977a081407010000000d000000da8a078478015208c084780003958800fe5108b58477000182185108308e7733001c9511d87b10207b15183308000002330500401e030000027b187b150849111001641833001e282e0288770150100883013308330733001a2878029511d87b10207b15187b161050100a588477ff0052170547330933050000023308004095560433070000020a0139070000027b16491108fc3f52479bae9d5e16641750100c06018477ff005217021133080133070133001a281d020050100e18012889019511a87b10507b15487b16403305000002641633070000023300100a0401805210805814805918805a1c8053805c04805708805b0c49112049112849113049113897aa2097882097bb2097cc20d4a909d42808951220d4b707d43c0a7b1a7b17087b18107b1918330704017c68017c69027c6a037c6b97880897991097aa18d4b8087c6b047c6c05d4a9097c6a067c650797cc08d4cb0b97aa10975518d45a0a956608d49808d4ba0a97aa20d4a8087b289522089577ff5207b4951920330705330805019588ff51080f829a959908510af5330704018210508215488216409511583200827808510814827a7ca9958bff95aa017b7a7b7b0828053309019597ff8e77957a01939a330702db8a0732009511c87b10307b15287b16207b1733070000027b1708491110004049111895170850101270821710821518ac574a821608c95707c856087b18087b1710491118951808821750101460821810821718ac7826821a08975920989920977720987b20330764680a038210308215288216209511383200003300169511f87b1033080000021f0300000233090233070a0200009511f07b100848110495180433090433002028199511f07b1008648a78170795180733090164a7330020019511e87b10107b15087b166475827710c89706ac7630825a08ac6a2a825ac8a7073300189511c87b10307b15287b162028e4fa7b5610821010821508821695111832000000838852080f330a330901330b00000228163308000002330a013b0a000002c8a80b330902019511f87b10330800000278ba0a02000082191052090b33080133070a0200835501ac590400330800000233070a0200821008951110320085924a29499244494992a432494a9924294d499a242949a94a92924952522649499394929249292949aa949292244428443824912449924852912492094948529224a926e524491212494900492212a52409114a9424549224115188844321508848922149120a699294244992244952924c52922449922449929224999464929454526a4a49495248482249922429922449aa24695208a9932429294999a4922425499224a54b098584640a75929a0c350900","build_info":{"rust_toolchain":"stable-aarch64-apple-darwin","cargo_contract_version":"6.0.0-beta","build_mode":"Release"}},"contract":{"name":"flipper","version":"6.0.0-beta","authors":["Use Ink <[email protected]>"]},"image":null,"version":6,"types":[{"id":0,"type":{"def":{"primitive":"bool"}}},{"id":1,"type":{"path":["flipper","flipper","Flipper"],"def":{"composite":{"fields":[{"name":"value","type":0,"typeName":"<bool as::ink::storage::traits::AutoStorableHint<::ink::storage\n::traits::ManualKey<2054318728u32, ()>,>>::Type"}]}}}},{"id":2,"type":{"path":["Result"],"params":[{"name":"T","type":3},{"name":"E","type":4}],"def":{"variant":{"variants":[{"name":"Ok","fields":[{"type":3}],"index":0},{"name":"Err","fields":[{"type":4}],"index":1}]}}}},{"id":3,"type":{"def":{"tuple":[]}}},{"id":4,"type":{"path":["ink_primitives","LangError"],"def":{"variant":{"variants":[{"name":"CouldNotReadInput","index":1}]}}}},{"id":5,"type":{"path":["Result"],"params":[{"name":"T","type":0},{"name":"E","type":4}],"def":{"variant":{"variants":[{"name":"Ok","fields":[{"type":0}],"index":0},{"name":"Err","fields":[{"type":4}],"index":1}]}}}},{"id":6,"type":{"path":["ink_primitives","types","AccountId"],"def":{"composite":{"fields":[{"type":7,"typeName":"[u8; 32]"}]}}}},{"id":7,"type":{"def":{"array":{"len":32,"type":8}}}},{"id":8,"type":{"def":{"primitive":"u8"}}},{"id":9,"type":{"def":{"primitive":"u128"}}},{"id":10,"type":{"path":["ink_primitives","types","Hash"],"def":{"composite":{"fields":[{"type":7,"typeName":"[u8; 32]"}]}}}},{"id":11,"type":{"def":{"primitive":"u64"}}},{"id":12,"type":{"def":{"primitive":"u32"}}}],"storage":{"root":{"root_key":"0x00000000","layout":{"struct":{"name":"Flipper","fields":[{"name":"value","layout":{"leaf":{"key":"0x00000000","ty":0}}}]}},"ty":1}},"spec":{"constructors":[{"label":"new","selector":"0x9bae9d5e","payable":false,"args":[{"label":"init_value","type":{"type":0,"displayName":["bool"]}}],"returnType":{"type":2,"displayName":["ink_primitives","ConstructorResult"]},"docs":["Creates a new flipper smart contract initialized with the given value."],"default":false}],"messages":[{"label":"flip","selector":"0x633aa551","mutates":true,"payable":false,"args":[],"returnType":{"type":2,"displayName":["ink","MessageResult"]},"docs":[" Flips the current value of the Flipper's boolean."],"default":false},{"label":"get","selector":"0x2f865bd9","mutates":false,"payable":false,"args":[],"returnType":{"type":5,"displayName":["ink","MessageResult"]},"docs":[" Returns the current value of the Flipper's boolean."],"default":false}],"events":[],"docs":[],"lang_error":{"type":4,"displayName":["ink","LangError"]},"environment":{"accountId":{"type":6,"displayName":["AccountId"]},"balance":{"type":9,"displayName":["Balance"]},"hash":{"type":10,"displayName":["Hash"]},"timestamp":{"type":11,"displayName":["Timestamp"]},"blockNumber":{"type":12,"displayName":["BlockNumber"]},"nativeToEthRatio":100000000,"staticBufferSize":16384}}}

cypress/fixtures/mother.contract

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

cypress/fixtures/multisig.contract

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

cypress/fixtures/storage_types.contract

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/lib/callOptions.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function transformUserInput(
5757
messageArgs: AbiParam[],
5858
values?: Record<string, unknown>,
5959
): unknown[] {
60-
return messageArgs.map(({ name, type: { type } }) => {
60+
return messageArgs.map(({ name, type: { type, displayName } }) => {
6161
const value = values ? values[name] : null;
6262

6363
if (type === 'Balance') {
@@ -67,6 +67,11 @@ export function transformUserInput(
6767
return registry.createType('U256', value);
6868
}
6969

70+
// H160 and Address types need explicit type creation
71+
if (type === 'H160' || type === 'Address' || displayName?.includes('Address')) {
72+
return registry.createType('H160', value);
73+
}
74+
7075
return value;
7176
});
7277
}

0 commit comments

Comments
 (0)