-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into estimate-gas-fee
- Loading branch information
Showing
15 changed files
with
701 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## Checklist before requesting a review | ||
|
||
- [ ] I have added documentation to README | ||
- [ ] I have performed a self-review of my code | ||
- [ ] I have tested this new feature or change on devnet and verified that it works |
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,35 @@ | ||
import { toStars } from '../src/utils'; | ||
import { getClient } from '../src/client'; | ||
|
||
const config = require('../config'); | ||
|
||
async function addGroupMember(member: string, weight: number) { | ||
const client = await getClient(); | ||
|
||
// @ts-ignore | ||
const msg: ExecuteMsg = { | ||
update_members: { add: [{ addr: toStars(member), weight: weight }] }, | ||
}; | ||
|
||
console.log('Adding member to cw4-group...'); | ||
|
||
const result = await client.execute( | ||
config.account, | ||
config.groupContract, | ||
msg, | ||
'auto' | ||
); | ||
|
||
const wasmEvent = result.logs[0].events.find((e) => e.type === 'wasm'); | ||
console.info( | ||
'The `wasm` event emitted by the contract execution:', | ||
wasmEvent | ||
); | ||
} | ||
|
||
const args = process.argv.slice(2); | ||
if (args[0] == 'add-member' && args.length == 3) { | ||
addGroupMember(args[1], parseInt(args[2])); | ||
} else { | ||
console.log('Invalid arguments'); | ||
} |
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,25 @@ | ||
import { getClient } from '../src/client'; | ||
import { ExecuteMsg } from '@stargazezone/launchpad/src/Splits.types'; | ||
|
||
|
||
const config = require('../config'); | ||
|
||
let distrubute_splits= async ()=>{ | ||
const client = await getClient(); | ||
const msg: ExecuteMsg = { | ||
distribute: { | ||
}, | ||
}; | ||
|
||
const result = await client.execute( | ||
config.account, | ||
config.splitsContract, | ||
msg, | ||
'auto', | ||
'distribute', | ||
); | ||
console.log('Distribute result:', result); | ||
|
||
} | ||
|
||
distrubute_splits(); |
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,78 @@ | ||
// start with snapshot.csv | ||
// output address and nft count to owner_nft_count.csv | ||
// burned nfts count gets added towards config.account address | ||
|
||
import { toStars } from '../src/utils'; | ||
import * as fs from 'fs'; | ||
import { appendFileSync } from 'fs'; | ||
import * as path from 'path'; | ||
import { parse } from 'csv-parse'; | ||
|
||
const config = require('../config'); | ||
const SNAPSHOT = 'snapshot.csv'; | ||
|
||
class TokenInfo { | ||
owner: string; | ||
tokenId: string; | ||
constructor(tokenId = '', owner = '') { | ||
this.owner = owner; | ||
this.tokenId = tokenId; | ||
} | ||
} | ||
|
||
class OwnerNftCount { | ||
address: string; | ||
count: number; | ||
constructor(address = '', count = 0) { | ||
this.address = address; | ||
this.count = count; | ||
} | ||
|
||
saveAsCSV() { | ||
const csv = `${this.address},${this.count}\n`; | ||
try { | ||
appendFileSync('./owner_nft_count.csv', csv); | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
} | ||
} | ||
|
||
async function queryNftCount() { | ||
const account = toStars(config.account); | ||
|
||
const __dirname = process.cwd(); | ||
const csvFilePath = path.resolve(__dirname, './' + SNAPSHOT); | ||
const headers = ['tokenId', 'owner']; | ||
const fileContent = fs.readFileSync(csvFilePath, { encoding: 'utf-8' }); | ||
const owners = new Map(); | ||
|
||
await parse( | ||
fileContent, | ||
{ | ||
delimiter: ',', | ||
columns: headers, | ||
}, | ||
async (error, fileContents: TokenInfo[]) => { | ||
if (error) { | ||
throw error; | ||
} | ||
fileContents.map((row) => { | ||
if (row.owner == 'burned') { | ||
row.owner = account; | ||
} | ||
if (owners.has(row.owner)) { | ||
owners.set(row.owner, owners.get(row.owner) + 1); | ||
} else { | ||
owners.set(row.owner, 1); | ||
} | ||
}); | ||
owners.forEach((count, addr) => { | ||
const row = new OwnerNftCount(addr, count); | ||
row.saveAsCSV(); | ||
}); | ||
} | ||
); | ||
} | ||
|
||
queryNftCount(); |
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,70 @@ | ||
import { CosmWasmClient } from 'cosmwasm'; | ||
import { toStars } from '../src/utils'; | ||
|
||
const config = require('../config'); | ||
let splitsAddress= config.splitsContract; | ||
|
||
async function querySplitsAdmin() { | ||
const client = await CosmWasmClient.connect(config.rpcEndpoint); | ||
const admin = await client.queryContractSmart(splitsAddress, { | ||
admin: {}, | ||
}); | ||
console.log('admin:', admin); | ||
} | ||
|
||
async function querySplitsGroup() { | ||
const client = await CosmWasmClient.connect(config.rpcEndpoint); | ||
const group = await client.queryContractSmart(splitsAddress, { | ||
group: {}, | ||
}); | ||
console.log('group:', group); | ||
} | ||
|
||
async function querySplitsMember(address: string) { | ||
const client = await CosmWasmClient.connect(config.rpcEndpoint); | ||
const member = await client.queryContractSmart(splitsAddress, { | ||
member: { | ||
address: toStars(address), | ||
}, | ||
}); | ||
console.log('member:', member); | ||
} | ||
|
||
async function querySplitsListMembers() { | ||
const client = await CosmWasmClient.connect(config.rpcEndpoint); | ||
const members = await client.queryContractSmart(splitsAddress, { | ||
list_members: { | ||
}, | ||
}); | ||
console.log('members:', members); | ||
} | ||
|
||
if(!process.argv[3]){ | ||
console.log('No query type specified'); | ||
console.log('Query types: admin, group, member <member-address>, list-members'); | ||
process.exit(1); | ||
} | ||
else if(process.argv[3] === 'admin'){ | ||
querySplitsAdmin(); | ||
} | ||
else if(process.argv[3] === 'group'){ | ||
querySplitsGroup(); | ||
} | ||
else if(process.argv[3] === 'member'){ | ||
if(!process.argv[4]){ | ||
console.log('No address is specified'); | ||
process.exit(1); | ||
} | ||
querySplitsMember(process.argv[4]); | ||
} | ||
else if(process.argv[3] === 'list-members'){ | ||
querySplitsListMembers(); | ||
} | ||
else{ | ||
console.log('Invalid query type'); | ||
process.exit(1); | ||
} | ||
|
||
|
||
|
||
|
Oops, something went wrong.