Skip to content

Commit

Permalink
single-nominator-pool
Browse files Browse the repository at this point in the history
  • Loading branch information
rise1507 committed Jul 23, 2023
1 parent 283095c commit aa1a554
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
2 changes: 2 additions & 0 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,8 @@ input {
}

#whitelist_info {
width: 100%;
word-wrap: break-word;
color: #666;
line-height: 24px;
}
Expand Down
16 changes: 12 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -718,15 +718,19 @@
// ADD WHITELIST POPUP

let addressForCheck = undefined;
let oldAddressForCheck = undefined;

const onWhitelistAddressInput = async () => {
const value = $('#whitelist_addressInput').value;
if (TonWeb.utils.Address.isValid(value)) {
addressForCheck = value;
$('#whitelist_info').innerText = 'Loading..';
const info = await checkSmartContract(tonweb, new TonWeb.utils.Address(value));
if (value === addressForCheck) {
$('#whitelist_info').innerText = info.text;
if (oldAddressForCheck !== addressForCheck) {
oldAddressForCheck = addressForCheck;
$('#whitelist_info').innerText = 'Loading..';
const info = await checkSmartContract(tonweb, new TonWeb.utils.Address(value));
if (value === addressForCheck) {
$('#whitelist_info').innerText = info.text;
}
}
} else {
$('#whitelist_info').innerText = 'Invalid address';
Expand Down Expand Up @@ -957,6 +961,10 @@
return;
}

if (new TonWeb.utils.Address(myAddress).toString(false) === new TonWeb.utils.Address(newAddress).toString(false)) {
return;
}

for (let address of createState.whitelistAddresses) {
if (new TonWeb.utils.Address(address).toString(false) === new TonWeb.utils.Address(newAddress).toString(false)) {
return;
Expand Down
19 changes: 18 additions & 1 deletion js/check-smart-contract.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const POOL_CODE_HEX = 'B5EE9C7241023A010009C2000114FF00F4A413F4BCF2C80B0102016202030202CE0405020120131402012006070065421D749AB02705203AA008E23AA0303F00114A002A45301BA8E1323D74AC0019C5B01D430D020D749AB021270DEDE02E46C218047F3E09DBC400B434C0FE900C083E9100DC6C23C88C4CCCC835D2708FE3C5200835C874C7CC2084139CDD12EE80B6CF2C38C02497C0F8B800F4C7F6CF1584B0002021081F09004F34C1C069B40830BFFCB852483042B729BE4830BFFCB8524830443729B80830BFC870442C3CB852600330DB3C5610C00193705711DE104C103B4A98DB3C085533DB3C1F0C12042CE30F5540DB3C105C104B103A497810561045103440330A0B0C0D03A257121110D30721C07922C06EB122C06423C077B121B1F2E04020B39E21D15616C000F2BD56152EBDF2BEDE22C064E30022C077925717E30D11168E1330041115040311140302111302571157115F03E30D0E0F1003341111D33F56165616DB3CE30F0B11100B10BF10BE10BD10BC10AB2122230028C88101001026CF0113CB0FCB0F01FA0201FA02C90104DB3C1202D8810100561652A2F40E6FA120B3951112A41112DE56122EBBF2E04182103B9ACA0001111B01A120C200F2E042111A8E82DB3C93307020E25613C0009401561AA094561AA001E25301A02CBEF2E0432AD765755614B603AA00B609B9F2E04401DB3C81010012561740BBF443082F2503A45611C0008F2156150410391028011118011111DB3C015618A18212540BE400BE8E845613DB3CDE8EA3571781010056155292F40E6FA131F2E045C88101001256164099F4435613DB3C4F0702E24F1F50770629303002FE5614C0FF56142DBAB0B38E9D1114C000F2E07981010056135272F40E6FA1F2E07ADB3C30C200F2E07B925714E211148020F00201D11113C079561356118307F40E6FA120B38E1982103B9ACA005613D76595800F7AA984E401111801BEF2E07B925717E2561695F404D31F3094306DF823E25614228307F40E6FA131F2D07C2F11016CF82303C8CA0013CB1F021114018307F443C8F40001111201CB1F02011112010F8307F44311128E830DDB3C913DE20C11100C10BF10BC30004A0CC8CB071BCB0F5009FA025007FA0215CC13F400F400CB1FCBFFCB07CB1FCB1FF400C9ED540201201516020120191A0109BBF19DB3C81F02016217180175AF3BED9E2B882F87B6ACC183FA0737D0F97042FA02183FC70FC0808029107A3E37D2904F816900698F98112CB781A802378101C8997100D9F32DC01F0109AC8B6D9E403302016E1B1C015DBBD05DB3C57105F0F6D7F8E1F228307F47C6FA5208E1002F40431D31F3052106F0250036F02029132E201B3E6303181F0201201D1E0117AE3EED9E0837AF8798B759C01F0276AA39DB3C5F06509A5F096D7F8EA98101005230F47C6FA5208E9802DB3C810100546380F40E6FA1312355206F0450036F02029132E201B3E6135F031F2F0244AB59DB3C5F06509A5F098101002359F40E6FA1F2E056DB3C8101004430F40E6FA1311F2F0154ED44D0D307D30FFA00FA00D401D0DB3C05F404F404D31FD3FFD307D31FD31FF4043010BC10AB109A108920001C810100D701D30FD30FFA00FA0030001E01C0FF71F833D0810100D70358BAB001E85B5712571257125712F8008210F96F732452E0BA8EB93B11117009A15380C1019A5088A020C100923727DE8E16305305A8812710A9045301BC923020DE5188A008A107E25077DB3C270A11110A080A925712E22AC0018E198210EE6F454C52D0BA92703BDE8210F374484C1DBA92723ADE913CE22404B85613C2005614C108B0821047657424561501BAB182104E73744B561501BAB1F2E0465613C001305613C0028F24D3071039102856180201111201DB3C5619A18212540BE400BE8E845614DB3CDE11104870DE5613C003E3005613C0062630272803BA707F8E988101005230F47C6FA5208E8702DB3C3013A0029132E201B3E6306D7F8F378101005240F47C6FA5208F2602DB3C25C2009F547715A98412A020C100923070DE01DEA070DB3C8101005412015055F443029132E201B3E6145F042F2F25000EC858FA0201FA020172707F218EB0810100542270F47C6FA532218E9C3254411348705266DB3C5217BA05A45304BE927F36DE103847634550DE01B322B112E65F0401290268810100D7018101005462A0F40E6FA131F2E0474930185618011112DB3C015619A18212540BE400BE8E845614DB3CDE1110487012293004D68F2024C103F2E071DB3C6C21F9005360BD99343503A44413F823039130E25614DB3CDE5613C0078EB7F8237F8E2C56148307F47C6FA5208E1C02F40431D31F305230A18208278D00BC9A2011168307F45B301115DE9132E201B3E65B5614DB3CDE821047657424561401BA3430302A03B2810100546550F40E6FA1F2BCDB3CA08212540BE4005230A15210BC93306C14E0810100544666F45B30810100544655F45B3001A55124A182103B9ACA005250BE8F11705006DB3C6D80101023102670DB3C1023923434E243302F393804E08F3024C201F2E06F24C202F82325A124A63CBCB1F2E070821047657424C8CB1F5220CB3FC9DB3C708018804010341023DB3CDE5613C0048E235616C0FF56162FBAB0F2E04982103B9ACA0001111901A120C200F2E04A51EEA00E1118DE5613C005925714E30D82104E73744B561301BA37382B2C04A85611C000F2E04A5616C0FF56162FBAB0F2E04BFA0021C200F2E04E29DB3C8212540BE400561A01A101A15220BBF2E04C51F1A120C100923070DE7F2FDB3C6D8010245970DB3C561858A15619A18212540BE400BE2D39382E014E8E173005111605041115040311140302111302571157115F04E30D0F11100F10EF10DE10CD10BC31013E707F8E988101005230F47C6FA5208E8702DB3CA013A0029132E201B3E630312F011C8E841114DB3C925714E20D11130D30000AFA00FA00300114706D8010804072A0DB3C3804D63E5F050FC0FF51E6BA1EB0F2E04E08C000F2E04F25F2E05082103B9ACA001FBEF2E05609FA0020DB3C82103B9ACA005230A18218746A5288005240BEF2E0518212540BE40001111001A15230BBF2E052535FBEF2E0532EDB3C5260BEF2E0542D6EF2E05571DB3C31F9007032333435001CD3FF31D31FD31F31D3FF31D431D100848028F833206E985B8218178411B200E0D0D30731FA00D31FD30FD30FD30F31D30F31D30FD30F305053A8AB075033A8AB075023A8AB0759A8AB075220A9B41FA0B60800268022F83320D0D30701C012F289D31FD31F3058035CDB3CDB3C1110C8CB1F1CCB3F5006CF16C9801871041110041038DB3C0E11100E1F103E102D10BC107B50990743133637380022800FF833D0D31F31D31F31D31F31D70B1F011A71F833D0810100D7037F01DB3C390048226EB32091719170E203C8CB055006CF165004FA02CB6A039358CC019130E201C901FB00001C74C8CB0212CA07810100CF01C9D0CA582994';
const POOL_CODE_BASE64 = TonWeb.utils.bytesToBase64(TonWeb.utils.hexToBytes(POOL_CODE_HEX));

const SINGLE_NOMINATOR_CODE_BASE64 = 'te6cckECDQEAAcUAART/APSkE/S88sgLAQIBYgIDAmjQ7UTQ+kD6QNEixwCSXwbgA9DTAwFxsJJfBuD6QDAC0x/TP1NDxwWRM+MNUjXHBZJfBuMNBAUCASALDAHEIoMLuo6g+gBTh6GCEDuaygChErYIgSAEIcIA8vRSQG2AGIBA2zzeIoEQAbqe+kBQRMhYzxYBzxbJ7VSRM+IhgXcCupgC0wfUAvsAAt4hggCZA7qdAtSBIAIibvLyAfsEAt4JBPAgghBOc3RLuo/hAvpEMPgo+kQwgSADAsD/EvL0gwwBwP/y9IEgASPy9IEgBSSCEEeGjAC+8vT6ACDbPDAFgSAEBaGCEDuaygChUhC7FPL02zyCEE5zdEvIyx9SMMs/UAXPFslEMIAYgEDbPJQQNWxB4oIQR2V0JLoGCAkHABzT/zHTH9MfMdP/MdQx0QI2jxaCEEdldCTIyx/LP8nbPHBYgBiAQNs8kTDiCAkBFnH4M9DXC/9/Ads8CgBIIm6zIJFxkXDiA8jLBVAGzxZQBPoCy2oDk1jMAZEw4gHJAfsAABZ0yMsCEsoHy//J0AAnvfjLk4uCo4ACo4ADa2qjkVKYi2wAFb/lB2omh9IH0gaMlehRQw==';

class PoolContract extends TonWeb.Contract {
constructor(provider, options) {
// <{ SETCP0 ACCEPT
Expand Down Expand Up @@ -73,6 +75,18 @@ const checkPool = async (tonweb, poolAddress) => {
}
}

const checkSingleNominator = async (tonweb, poolAddress) => {
const data = await tonweb.provider.call2(poolAddress, 'get_roles');

const ownerAddress = data[0].beginParse().loadAddress();
const validatorAddress = data[1].beginParse().loadAddress();

return {
status: SUCCESS,
text: 'Single nominator, owner is ' + ownerAddress.toString(true, true, true) + ' (MUST BE EQUAL VESTING-WALLET ADDRESS), validator is ' + validatorAddress.toString(true, true, true)
};
}

/**
* @param tonweb {TonWeb}
* @param address {Address}
Expand Down Expand Up @@ -111,14 +125,17 @@ const checkSmartContract = async (tonweb, address) => {
}
if (info.code === POOL_CODE_BASE64) {
return checkPool(tonweb, addressString);
} else if (info.code === SINGLE_NOMINATOR_CODE_BASE64) {

return checkSingleNominator(tonweb, addressString);

} else {
const walletInfo = await tonweb.provider.getWalletInfo(addressString);
return {
status: SUCCESS,
text: walletInfo.wallet === true ? walletInfo.wallet_type : 'Unknown account - not wallet, not nominator pool'
};

// todo: single-nominator-pool
// todo: whales pools addresses
// todo: tonstakers-pool
// todo: tonstakers jetton-wallet
Expand Down
2 changes: 1 addition & 1 deletion lib/tonweb-0.0.61.js

Large diffs are not rendered by default.

0 comments on commit aa1a554

Please sign in to comment.