-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
673 additions
and
7 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+36.3 KB
...ansfer/__image_snapshots__/Sign transaction shows ContractCallTx details #0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+47.1 KB
...sfer/__image_snapshots__/Sign transaction shows ContractCreateTx details #0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+25.7 KB
.../transfer/__image_snapshots__/Sign transaction shows NameClaimTx details #0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+27.3 KB
...ansfer/__image_snapshots__/Sign transaction shows NamePreclaimTx details #0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+45.5 KB
...transfer/__image_snapshots__/Sign transaction shows NameRevokeTx details #0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+35.8 KB
...ansfer/__image_snapshots__/Sign transaction shows NameTransferTx details #0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+35.2 KB
...transfer/__image_snapshots__/Sign transaction shows NameUpdateTx details #0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+34.9 KB
...ansfer/__image_snapshots__/Sign transaction shows OracleExtendTx details #0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+54.3 KB
...ransfer/__image_snapshots__/Sign transaction shows OracleQueryTx details #0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+46.2 KB
...sfer/__image_snapshots__/Sign transaction shows OracleRegisterTx details #0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+50.6 KB
...sfer/__image_snapshots__/Sign transaction shows OracleResponseTx details #0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+36.8 KB
...pecs/transfer/__image_snapshots__/Sign transaction shows SpendTx details #0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+44.7 KB
...2e/specs/transfer/__image_snapshots__/Sign transaction signs transaction #0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
import { | ||
buildTx, unpackTx, Tag, encode, decode, commitmentHash, Encoding, ORACLE_TTL_TYPES, oracleQueryId, | ||
} from '@aeternity/aepp-sdk-next'; | ||
|
||
describe('Sign transaction', () => { | ||
const nonce = 1; | ||
const nameTtl = 1; | ||
const clientTtl = 1; | ||
const amount = 12.34e18; | ||
const accountId = 'ak_2iBPH7HUz3cSDVEUWiHg76MZJ6tZooVNBmmxcgVK6VV8KAE688'; | ||
const recipientId = 'ak_2iBPH7HUz3cSDVEUWiHg76MZJ6tZooVNBmmxcgVK6VV8KAE688'; | ||
const name = 'test123test.chain'; | ||
const nameId = 'nm_2sFnPHi5ziAqhdApSpRBsYdomCahtmk3YGNZKYUTtUNpVSMccC'; | ||
const nameFee = '1000000000000000000000'; | ||
const pointers = [{ key: 'account_pubkey', id: accountId }]; | ||
const payload = encode(Buffer.from('test'), Encoding.Bytearray); | ||
const queryFormat = '{\'city\': str}'; | ||
const responseFormat = '{\'tmp\': num}'; | ||
const queryFee = 30000; | ||
const oracleTtl = { oracleTtlType: ORACLE_TTL_TYPES.delta, oracleTtlValue: 500 }; | ||
const responseTtl = { responseTtlType: ORACLE_TTL_TYPES.delta, responseTtlValue: 100 }; | ||
const queryTtl = { queryTtlType: ORACLE_TTL_TYPES.delta, queryTtlValue: 100 }; | ||
const query = '{\'city\': \'Berlin\'}'; | ||
const queryResponse = '{\'tmp\': 101}'; | ||
const callData = 'cb_KxFs8lcLG2+HEPb2FOjjZ2DqRd4='; | ||
const gasLimit = 5e6; | ||
const nameSalt = 4204563566073083; | ||
const commitmentId = commitmentHash(name, nameSalt); | ||
const contractId = 'ct_TCQVoset7Y4qEyV5tgEAJAqa2Foz8J1EXqoGpq3fB6dWH5roe'; | ||
const oracleId = encode(decode(accountId), Encoding.OracleAddress); | ||
|
||
const transactions = [{ | ||
tag: Tag.SpendTx, senderId: accountId, recipientId: accountId, nonce, amount, payload, | ||
}, { | ||
tag: Tag.NamePreclaimTx, accountId, nonce, commitmentId, | ||
}, { | ||
tag: Tag.NameClaimTx, accountId, nonce, name, nameSalt, nameFee, | ||
}, { | ||
tag: Tag.NameUpdateTx, accountId, nonce, nameId, nameTtl, pointers, clientTtl, | ||
}, { | ||
tag: Tag.NameRevokeTx, accountId, nonce, nameId, | ||
}, { | ||
tag: Tag.NameTransferTx, accountId, nonce, nameId, recipientId, | ||
}, { | ||
tag: Tag.ContractCreateTx, | ||
nonce, | ||
ownerId: accountId, | ||
code: 'cb_+ExGA6Dh3797nquCHCSm088avgOiqgjjarRQviEYAXq+YlegWcCgjf6AeCCSADcBBwcBAQCOLwERgHggkhlnZXRBcmeCLwCFNy4wLjEALb9eTg==', | ||
amount, | ||
gasLimit, | ||
callData, | ||
}, { | ||
tag: Tag.ContractCallTx, | ||
nonce, | ||
callerId: accountId, | ||
contractId, | ||
amount, | ||
gasLimit, | ||
callData, | ||
}, { | ||
tag: Tag.OracleRegisterTx, | ||
nonce, | ||
accountId, | ||
queryFormat, | ||
responseFormat, | ||
queryFee, | ||
...oracleTtl, | ||
}, { | ||
tag: Tag.OracleExtendTx, nonce, oracleId, ...oracleTtl, | ||
}, { | ||
tag: Tag.OracleQueryTx, | ||
nonce, | ||
oracleId, | ||
...responseTtl, | ||
query, | ||
...queryTtl, | ||
queryFee, | ||
senderId: accountId, | ||
}, { | ||
tag: Tag.OracleResponseTx, | ||
nonce, | ||
oracleId, | ||
...responseTtl, | ||
queryId: oracleQueryId(accountId, nonce, oracleId), | ||
response: queryResponse, | ||
}]; | ||
|
||
transactions.forEach((txParams) => { | ||
it(`shows ${Tag[txParams.tag]} details`, () => { | ||
const url = new URL('http://localhost/signTransaction'); | ||
url.searchParams.append('param0', `"${buildTx(txParams)}"`); | ||
url.searchParams.append('callback', 'about:blank'); | ||
cy | ||
.viewport('iphone-se2') | ||
.visit(url.href.replace('http://localhost', ''), { login: true }); | ||
cy.get('.page.primary').should('be.visible'); | ||
cy.matchImage(); | ||
}); | ||
}); | ||
|
||
it('signs transaction', () => { | ||
const url = new URL('http://localhost/signTransaction'); | ||
url.searchParams.append('param0', `"${buildTx(transactions[0])}"`); | ||
url.searchParams.append('callback', 'about:blank'); | ||
cy | ||
.viewport('iphone-se2') | ||
.visit(url.href.replace('http://localhost', ''), { login: true }); | ||
cy.get('button').contains('Confirm').click(); | ||
const skipButton = cy.get('.modal-plain .ae-button.primary'); | ||
cy.matchImage(); | ||
skipButton.click(); | ||
|
||
cy.url().should('contain', 'about:blank').then((u) => { | ||
const resultUrl = new URL(u); | ||
const signedTx = resultUrl.searchParams.get('result'); | ||
const txParams = unpackTx(JSON.parse(decodeURIComponent(signedTx)), Tag.SignedTx); | ||
expect(txParams.signatures).to.have.length(1); | ||
}); | ||
}); | ||
|
||
it('cancel transaction signing', () => { | ||
const url = new URL('http://localhost/signTransaction'); | ||
url.searchParams.append('param0', `"${buildTx(transactions[0])}"`); | ||
url.searchParams.append('callback', 'about:blank'); | ||
cy | ||
.viewport('iphone-se2') | ||
.visit(url.href.replace('http://localhost', ''), { login: true }); | ||
cy.get('button').contains('Cancel').click(); | ||
cy.url().should('equal', 'about:blank?error=Rejected+by+user'); | ||
}); | ||
}); |