-
Notifications
You must be signed in to change notification settings - Fork 1
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
Implement revokeDelegation(ByDelegator|ByProvider) #514
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
96db795
chore: various fixes to get e2e tests working
mattheworris 986927f
fix: docker and makefile changes to get things working
mattheworris b95c232
chore: update README with correct instructions for e2e tests
mattheworris 2e39aac
Merge branch 'chore/fix-account-e2e-test' of github.com:ProjectLibert…
mattheworris e01e5eb
feat: implement GET and tested successfully
mattheworris a169d1d
feat: implement scaffold for POST endpoint: builds without errors
mattheworris 36e289f
fix: updated implementation to use signature instead of signer
mattheworris d72e97c
Merge branch 'main' of github.com:ProjectLibertyLabs/gateway into pos…
mattheworris fbe7429
fix: e2e test
mattheworris 8d5ce65
fix: remove config file
mattheworris 1b1919e
fix: address comments
mattheworris ba3791d
fix: add validations for GET revokeDelegation
mattheworris 6cfc31a
Merge branch 'main' of github.com:ProjectLibertyLabs/gateway into pos…
mattheworris 89046ac
fix: Dependency cycle
mattheworris File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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,57 @@ | ||
import { ChainUser, ExtrinsicHelper, initialize } from '@projectlibertylabs/frequency-scenario-template'; | ||
import log from 'loglevel'; | ||
import { cryptoWaitReady } from '@polkadot/util-crypto'; | ||
import { hexToU8a, u8aToHex } from '@polkadot/util'; | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import axios from 'axios'; | ||
// eslint-disable-next-line import/no-relative-packages | ||
import { setupProviderAndUsers } from '../e2e-setup.mock.spec'; | ||
|
||
const FREQUENCY_URL = process.env.FREQUENCY_URL || 'ws://127.0.0.1:9944'; | ||
|
||
async function main() { | ||
await cryptoWaitReady(); | ||
log.setLevel('trace'); | ||
console.log('Connecting...'); | ||
await initialize(FREQUENCY_URL); | ||
|
||
// eslint-disable-next-line no-use-before-define | ||
await revokeDelegation(); | ||
} | ||
|
||
async function revokeDelegation() { | ||
await cryptoWaitReady(); | ||
const { provider, users } = await setupProviderAndUsers(); | ||
const providerId = provider.msaId?.toString(); | ||
const { keypair } = users[1]; | ||
const accountId = keypair.address; | ||
const getPath: string = `http:/localhost:3013/v1/delegation/revokeDelegation/${accountId}/${providerId}`; | ||
const response = await axios.get(getPath); | ||
const revokeDelegationPayloadResponse = response.data; | ||
console.log(`RevokeDelegationPayloadResponse = ${JSON.stringify(revokeDelegationPayloadResponse)}`); | ||
|
||
// From github:https://github.com/polkadot-js/tools/issues/175 | ||
// Use the withType option to sign the payload to get the prefix 0x01 | ||
// which specifies the SR25519 type of the signature and avoids getting and error about an enum in the next signAsync step | ||
const signature: Uint8Array = keypair.sign(revokeDelegationPayloadResponse.payloadToSign, { withType: true }); | ||
console.log('signature:', u8aToHex(signature)); | ||
|
||
const revokeDelegationRequest = { | ||
accountId, | ||
providerId, | ||
encodedExtrinsic: revokeDelegationPayloadResponse.encodedExtrinsic, | ||
payloadToSign: revokeDelegationPayloadResponse.payloadToSign, | ||
signature: u8aToHex(signature), | ||
}; | ||
console.log(`revokeDelegationRequest = ${JSON.stringify(revokeDelegationRequest)}`); | ||
|
||
const postPath = 'http:/localhost:3013/v1/delegation/revokeDelegation'; | ||
await axios.post(postPath, revokeDelegationRequest); | ||
} | ||
|
||
main() | ||
.catch((r) => { | ||
console.error(r); | ||
process.exit(1); | ||
}) | ||
.finally(process.exit); |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could either:
(GET) /v1/delegation/revokeDelegation/:accountId/:providerId
specifically, -OR-expect
statements here to validate the response payload, and continue on to POST