Skip to content

Commit

Permalink
MSO-114 (#199)
Browse files Browse the repository at this point in the history
* mso-114

* action
  • Loading branch information
leecchh authored Nov 6, 2024
1 parent 618b6d1 commit d28f41d
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 74 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/suins-build-tx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- Profits to Treasury
- Transfer Reserved Names
- Free Coupons
- Create Coupons
sui_tools_image:
description: 'image reference of sui_tools'
default: 'mysten/sui-tools:mainnet'
Expand Down Expand Up @@ -114,6 +115,17 @@ jobs:
run: |
cd scripts && pnpm ts-node transactions/free-three-digit.ts
- name: Create Coupons
if: ${{ inputs.transaction_type == 'Create Coupons' }}
env:
NODE_ENV: production
GAS_OBJECT: ${{ inputs.gas_object_id }}
NETWORK: mainnet
ORIGIN: gh_action
RPC_URL: ${{ inputs.rpc }}
run: |
cd scripts && pnpm ts-node transactions/create-bulk-coupons.ts
- name: Show Transaction Data (To sign)
run: |
cat scripts/tx/tx-data.txt
Expand Down
163 changes: 89 additions & 74 deletions scripts/transactions/create-bulk-coupons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,85 +24,100 @@ const create = async () => {

const tx = new Transaction();

const freeCouponAddress = '0x11469060268ba1d611e3ad95f3134332f68e21198ce068a14f30975336be9ca1';
const freeCouponAddresses25 = [
'0xd7087d60e4c945e14c74e7037b6f31ec8a7fd70a761844cd7c80b787301c9dab',
'0x9335c256a5338ac356dd21a21fe5f615b2a60557d95834ba92f67eedcd6aecff',
'0xa625325b6f2f955a2db9183f450419df276fbf171e5e63293799f797bd79673b', //jmorgs
'0x96196979add1646bc54d395829da9feac4baf4d56a94089f4e232034ecb091ab', //saevon
'0xbb684e2faca83054dcf28e19cad91225647b76db76fff59f92114cd84479c853', //louisa
'0x19b801391d32790263ce571ea0c52433dc7f1976ea48636981a6e12be695c7f3', //boon
];

for (const freeCouponAddress of freeCouponAddresses25) {
new PercentageOffCoupon(100)
.setName(freeCouponAddress)
.setAvailableClaims(25)
.setYears([1, 1])
.setUser(freeCouponAddress)
.toTransaction(tx, pkg);
}

const freeCouponAddress350 = '0xe347045b6f10cd3390aaa6971cd4b2395842ff9eac5fb4eac0cf2eee52e4fa2c';
new PercentageOffCoupon(100)
.setName(freeCouponAddress)
.setAvailableClaims(200)
.setName(freeCouponAddress350)
.setAvailableClaims(350)
.setYears([1, 1])
.setUser(freeCouponAddress)
.setUser(freeCouponAddress350)
.toTransaction(tx, pkg);

const lengthRange = optionalRangeConstructor(tx, pkg, [3, 63]);
const yearsRange = optionalRangeConstructor(tx, pkg, [1, 1]);

// for batch operations with same setup coupons, we can create the coupon rules
// once and re-use them (as they can be copied on-chain).
const rules = newCouponRules(
tx,
pkg,
{
availableClaims: 1,
},
lengthRange,
yearsRange,
);

const coupons80Off = [];

// create 300 80% coupons
for (let i = 0; i < 300; i++) {
const coupon = generateRandomString(16);
coupons80Off.push(coupon);
new PercentageOffCoupon(80).setName(coupon).toTransaction(tx, pkg, rules);
}

const coupons25Off = [];

// create 500 25% coupons.
for (let i = 0; i < 500; i++) {
const coupon = generateRandomString(16);
coupons25Off.push(coupon);
new PercentageOffCoupon(25).setName(coupon).toTransaction(tx, pkg, rules);
}

console.log('******** 80% Coupons ********');
console.dir(coupons80Off, { depth: null });
console.log('******** 25% Coupons ********');
console.dir(coupons25Off, { depth: null });

const lengthRange2 = optionalRangeConstructor(tx, pkg, [3, 3]);
const yearsRange2 = optionalRangeConstructor(tx, pkg, [1, 1]);

const rules2 = newCouponRules(
tx,
pkg,
{
expiration: '1729656000000',
},
lengthRange2,
yearsRange2,
);

const unlimitedCoupon = [];

// create 30% coupons for 3 length names
const coupon = generateRandomString(16);
unlimitedCoupon.push(coupon);
new PercentageOffCoupon(30).setName(coupon).toTransaction(tx, pkg, rules2);

writeFileSync(
'./tx/coupon-list.json',
JSON.stringify(
{
coupons80Off,
coupons25Off,
unlimitedCoupon,
},
null,
2,
),
);
// const lengthRange = optionalRangeConstructor(tx, pkg, [3, 63]);
// const yearsRange = optionalRangeConstructor(tx, pkg, [1, 1]);

// // for batch operations with same setup coupons, we can create the coupon rules
// // once and re-use them (as they can be copied on-chain).
// const rules = newCouponRules(
// tx,
// pkg,
// {
// availableClaims: 1,
// },
// lengthRange,
// yearsRange,
// );

// const coupons80Off = [];

// // create 300 80% coupons
// for (let i = 0; i < 300; i++) {
// const coupon = generateRandomString(16);
// coupons80Off.push(coupon);
// new PercentageOffCoupon(80).setName(coupon).toTransaction(tx, pkg, rules);
// }

// const coupons25Off = [];

// // create 500 25% coupons.
// for (let i = 0; i < 500; i++) {
// const coupon = generateRandomString(16);
// coupons25Off.push(coupon);
// new PercentageOffCoupon(25).setName(coupon).toTransaction(tx, pkg, rules);
// }

// console.log('******** 80% Coupons ********');
// console.dir(coupons80Off, { depth: null });
// console.log('******** 25% Coupons ********');
// console.dir(coupons25Off, { depth: null });

// const lengthRange2 = optionalRangeConstructor(tx, pkg, [3, 3]);
// const yearsRange2 = optionalRangeConstructor(tx, pkg, [1, 1]);

// const rules2 = newCouponRules(
// tx,
// pkg,
// {
// expiration: '1729656000000',
// },
// lengthRange2,
// yearsRange2,
// );

// const unlimitedCoupon = [];

// // create 30% coupons for 3 length names
// const coupon = generateRandomString(16);
// unlimitedCoupon.push(coupon);
// new PercentageOffCoupon(30).setName(coupon).toTransaction(tx, pkg, rules2);

// writeFileSync(
// './tx/coupon-list.json',
// JSON.stringify(
// {
// couponsOff,
// },
// null,
// 2,
// ),
// );

await prepareMultisigTx(tx, 'mainnet', pkg.adminAddress);
};
Expand Down

0 comments on commit d28f41d

Please sign in to comment.