-
Notifications
You must be signed in to change notification settings - Fork 8
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
1 parent
7ac74ed
commit 024efb0
Showing
8 changed files
with
642 additions
and
444 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { areYouSureAnswer, setup, commonTxOperations } from './utils'; | ||
import prompts, { PromptObject } from 'prompts'; | ||
import { exit } from 'process'; | ||
import { | ||
Transaction, | ||
ContractCallPayloadBuilder, | ||
ContractFunction, | ||
Address, | ||
TypedValue, | ||
AddressValue, | ||
} from '@elrondnetwork/erdjs'; | ||
import { | ||
chain, | ||
shortChainId, | ||
commonBuiltInOpertationsGasLimit, | ||
} from './config'; | ||
|
||
export const changeOwnerAddress = async () => { | ||
const promptQuestion: PromptObject[] = [ | ||
{ | ||
type: 'text', | ||
name: 'smartContractAddress', | ||
message: | ||
'Please provide the smart contract address where the wallet (PEM) you use is an owner.\n', | ||
validate: (value) => (!value ? 'Required!' : true), | ||
}, | ||
{ | ||
type: 'text', | ||
name: 'newOwnerAddress', | ||
message: | ||
'Please provide the wallet address of the new smart contract owner.\n', | ||
validate: (value) => (!value ? 'Required!' : true), | ||
}, | ||
]; | ||
|
||
try { | ||
const { smartContractAddress, newOwnerAddress } = await prompts( | ||
promptQuestion | ||
); | ||
|
||
if (!smartContractAddress || !newOwnerAddress) { | ||
console.log( | ||
"You have to provide the smart contract address and the new owner's address!" | ||
); | ||
exit(); | ||
} | ||
|
||
await areYouSureAnswer(); | ||
|
||
const { signer, userAccount, provider } = await setup(); | ||
|
||
const args: TypedValue[] = [new AddressValue(new Address(newOwnerAddress))]; | ||
|
||
const data = new ContractCallPayloadBuilder() | ||
.setFunction(new ContractFunction('ChangeOwnerAddress')) | ||
.setArgs(args) | ||
.build(); | ||
|
||
const tx = new Transaction({ | ||
data, | ||
gasLimit: commonBuiltInOpertationsGasLimit, | ||
receiver: new Address(smartContractAddress), | ||
sender: signer.getAddress(), | ||
value: 0, | ||
chainID: shortChainId[chain], | ||
}); | ||
|
||
await commonTxOperations(tx, userAccount, signer, provider); | ||
} catch (e: any) { | ||
console.log(e.message); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { areYouSureAnswer, setup, commonTxOperations } from './utils'; | ||
import prompts, { PromptObject } from 'prompts'; | ||
import { exit } from 'process'; | ||
import { | ||
Transaction, | ||
ContractCallPayloadBuilder, | ||
ContractFunction, | ||
Address, | ||
} from '@elrondnetwork/erdjs'; | ||
import { | ||
chain, | ||
shortChainId, | ||
commonBuiltInOpertationsGasLimit, | ||
} from './config'; | ||
|
||
export const claimDeveloperRewards = async () => { | ||
const promptQuestion: PromptObject[] = [ | ||
{ | ||
type: 'text', | ||
name: 'smartContractAddress', | ||
message: | ||
'Please provide the smart contract address where the wallet (PEM) you use is an owner.\n', | ||
validate: (value) => (!value ? 'Required!' : true), | ||
}, | ||
]; | ||
|
||
try { | ||
const { smartContractAddress } = await prompts(promptQuestion); | ||
|
||
if (!smartContractAddress) { | ||
console.log('You have to provide the smart contract address!'); | ||
exit(); | ||
} | ||
|
||
await areYouSureAnswer(); | ||
|
||
const { signer, userAccount, provider } = await setup(); | ||
|
||
const data = new ContractCallPayloadBuilder() | ||
.setFunction(new ContractFunction('ClaimDeveloperRewards')) | ||
.build(); | ||
|
||
const tx = new Transaction({ | ||
data, | ||
gasLimit: commonBuiltInOpertationsGasLimit, | ||
receiver: new Address(smartContractAddress), | ||
sender: signer.getAddress(), | ||
value: 0, | ||
chainID: shortChainId[chain], | ||
}); | ||
|
||
await commonTxOperations(tx, userAccount, signer, provider); | ||
} catch (e: any) { | ||
console.log(e.message); | ||
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
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