Skip to content

Commit e9dd657

Browse files
committed
🎂 Rename TCKT -> KPass
1 parent 0e428c2 commit e9dd657

10 files changed

+73
-72
lines changed

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const kimlikdao = new KimlikDAO({
1515
});
1616

1717
// In an async function
18-
const tckt = await kimlikdao.getValidated(kimlikdao.TCKT, [
18+
const kpass = await kimlikdao.getValidated(kimlikdao.KPass, [
1919
"personInfo",
2020
"addressInfo",
2121
"contactInfo",

‎client/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build/client/index.js: client/index.js client/index.d.js \
44
lib/crypto/sha3.js lib/crypto/secp256k1.js lib/crypto/modular.js \
55
lib/crypto/wesolowski.js lib/crypto/primes.js \
66
lib/did/*.js \
7-
lib/ethereum/*.d.js lib/ethereum/TCKTLite.js \
7+
lib/ethereum/*.d.js lib/ethereum/KPassLite.js \
88
lib/ethereum/evm.js \
99
lib/node/*.d.js lib/node/ipfs.js \
1010
lib/util/çevir.js

‎lib

Submodule lib updated 53 files
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,31 @@
11
import jsonrpc from "/lib/api/jsonrpc";
2+
import { ChainId } from "/lib/crosschain/chains";
3+
import KPassLite from "/lib/ethereum/KPassLite";
24
import evm from "/lib/ethereum/evm";
35

4-
/**
5-
* @const {string}
6-
* @noinline
7-
*/
8-
const TCKT_ADDR = "0xcCc0a9b023177549fcf26c947edb5bfD9B230cCc";
9-
106
/**
117
* @constructor
128
*
13-
* @param {!Object<string, string>} nodeUrls
9+
* @param {!Object<ChainId, string>} nodeUrls
1410
*/
15-
function TCKT(nodeUrls) {
16-
/** @const {!Object<string, string>} */
11+
function KPass(nodeUrls) {
12+
/** @const {!Object<ChainId, string>} */
1713
this.nodeUrls = nodeUrls;
1814
}
1915

16+
KPass.prototype.ADDRS = KPassLite.KPASS_ADDRS;
17+
2018
/**
2119
* Note exposure reports are filed only on Avalanche C-chain therefore this
2220
* method does not take a `chainId`.
2321
*
2422
* @param {string} exposureReportID of length 64, hex encoded exposureReportID.
2523
* @return {!Promise<number>} the timestamp of the last exposure report or zero.
2624
*/
27-
TCKT.prototype.exposureReported = function (exposureReportID) {
28-
return jsonrpc.call(this.nodeUrls["0xa86a"], 'eth_call', [
25+
KPass.prototype.exposureReported = function (exposureReportID) {
26+
return jsonrpc.call(this.nodeUrls[ChainId.x144], 'eth_call', [
2927
/** @type {!eth.Transaction} */({
30-
to: TCKT_ADDR,
28+
to: KPassLite.getAddress(ChainId.x144),
3129
data: "0x72797221" + exposureReportID
3230
}), "latest"
3331
]).then((/** @type {string} */ hexValue) => parseInt(hexValue.slice(-10), 16));
@@ -40,12 +38,12 @@ TCKT.prototype.exposureReported = function (exposureReportID) {
4038
* @param {string} address
4139
* @return {!Promise<number>} the last revoke timestamp.
4240
*/
43-
TCKT.prototype.lastRevokeTimestamp = function (address) {
41+
KPass.prototype.lastRevokeTimestamp = function (address) {
4442
/** @const {!Array<Promise<number>>} */
45-
const promises = Object.values(this.nodeUrls).map((nodeUrl) =>
43+
const promises = Object.entries(this.nodeUrls).map(([/** ChainId */ chainId, nodeUrl]) =>
4644
jsonrpc.call(nodeUrl, 'eth_call', [
4745
/** @type {!eth.Transaction} */({
48-
to: TCKT_ADDR,
46+
to: KPassLite.getAddress(chainId),
4947
data: "0x6a0d104e" + evm.address(address)
5048
}), "latest"
5149
]).then((/** @type {string} */ hexValue) => parseInt(hexValue.slice(-10), 16))
@@ -56,19 +54,19 @@ TCKT.prototype.lastRevokeTimestamp = function (address) {
5654
}
5755

5856
/**
59-
* @param {string} chainId
57+
* @param {ChainId} chainId
6058
* @param {string} address
6159
* @return {!Promise<string>} the IPFS handle of the address, encoded as a
6260
* length 66 hex string.
6361
*/
64-
TCKT.prototype.handleOf = function (chainId, address) {
62+
KPass.prototype.handleOf = function (chainId, address) {
6563
return /** @type {!Promise<string>} */(jsonrpc.call(this.nodeUrls[chainId],
6664
'eth_call', [
6765
/** @type {!eth.Transaction} */({
68-
to: TCKT_ADDR,
66+
to: KPassLite.getAddress(chainId),
6967
data: "0xc50a1514" + evm.address(address)
7068
}), "latest"
7169
]));
7270
}
7371

74-
export { TCKT, TCKT_ADDR };
72+
export { KPass };

‎server-js/TCKTSigners.js ‎server-js/KPassSigners.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,27 @@ import evm from "/lib/ethereum/evm";
77
* @const {string}
88
* @noinline
99
*/
10-
const TCKT_SIGNERS = "0xcCc09aA0d174271259D093C598FCe9Feb2791cCc";
10+
const KPASS_SIGNERS = "0xcCc09aA0d174271259D093C598FCe9Feb2791cCc";
1111

1212
/**
1313
* @constructor
1414
*
1515
* @param {!Object<string, string>} nodeUrls
1616
*/
17-
function TCKTSigners(nodeUrls) {
17+
function KPassSigners(nodeUrls) {
1818
/** @const {!Object<string, string>} */
1919
this.nodeUrls = nodeUrls;
2020
}
2121

2222
/**
23-
* Temporary validation method, before the TCKTSigners contract
23+
* Temporary validation method, before the KPassSigners contract
2424
* is deployed.
2525
*
2626
* @param {!did.DecryptedSections} decryptedSections
2727
* @param {string} ownerAddress
2828
* @return {!Promise<!kimlikdao.ValidationReport>}
2929
*/
30-
TCKTSigners.prototype.validateSignersTemporary = function (decryptedSections, ownerAddress) {
30+
KPassSigners.prototype.validateSignersTemporary = function (decryptedSections, ownerAddress) {
3131
/** @const {!kimlikdao.ValidationReport} */
3232
const validationReport = {
3333
isValid: true,
@@ -74,7 +74,7 @@ TCKTSigners.prototype.validateSignersTemporary = function (decryptedSections, ow
7474
* @param {string} ownerAddress
7575
* @return {!Promise<!kimlikdao.ValidationReport>}
7676
*/
77-
TCKTSigners.prototype.validateSigners = function (decryptedSections, ownerAddress) {
77+
KPassSigners.prototype.validateSigners = function (decryptedSections, ownerAddress) {
7878
/** @const {!Set<string>} */
7979
const allSigners = new Set();
8080
/** @const {!Object<string, !Array<string>>} */
@@ -90,15 +90,15 @@ TCKTSigners.prototype.validateSigners = function (decryptedSections, ownerAddres
9090
/** @const {!Array<!Array<*>>} */
9191
const paramsList = allSignersList.map((signer) => [/** @type {!eth.Transaction} */({
9292
data: "0x2796d3f1" + evm.address(signer),
93-
to: TCKT_SIGNERS
93+
to: KPASS_SIGNERS
9494
}),
9595
"latest"]);
9696
paramsList.push([/** @type {!eth.Transaction} */({
9797
data: "0x46fc4be1", // signerCountNeeded()
98-
to: TCKT_SIGNERS
98+
to: KPASS_SIGNERS
9999
}), "latest"], [/** @type {!eth.Transaction} */({
100100
data: "0xc8676ec4", // signerStakeNeeded()
101-
to: TCKT_SIGNERS
101+
to: KPASS_SIGNERS
102102
}), "latest"]);
103103

104104
return jsonrpc.callMulti(this.nodeUrls['0xa86a'],
@@ -169,4 +169,4 @@ TCKTSigners.prototype.validateSigners = function (decryptedSections, ownerAddres
169169
})
170170
}
171171

172-
export { TCKTSigners };
172+
export { KPassSigners };

‎server-js/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
include server-js/test/Makefile
22

33
build/server-js/index.js: server-js/index.js server-js/validator.js \
4-
server-js/TCKT.js server-js/TCKTSigners.js \
4+
server-js/KPass.js server-js/KPassSigners.js \
55
api/*.d.js api/error.js api/validationReport.js \
66
lib/api/jsonrpc.d.js lib/api/jsonrpc.js \
77
lib/crosschain/*.js \
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { KPass } from "../KPass";
2+
import { ChainId } from "/lib/crosschain/chains";
3+
import { assertEq } from "/lib/testing/assert";
4+
5+
const testHandleOf = () => {
6+
const kpass = new KPass({
7+
[ChainId.xa86a]: "https://api.avax.network/ext/bc/C/rpc"
8+
});
9+
return kpass.handleOf(ChainId.xa86a, "0x9697bde39a925ee3feb7a1d6230b00fbed99fd31")
10+
.then((handle) =>
11+
assertEq(handle, "0xa56d70606509f963753cf6079c736def8f26823a2c544fd70eab41faf82d4a25"))
12+
.catch(console.log);
13+
}
14+
15+
const testLastRevokeTimestamp = () => {
16+
const kpass = new KPass({
17+
[ChainId.xa86a]: "https://api.avax.network/ext/bc/C/rpc"
18+
});
19+
return kpass.lastRevokeTimestamp("0x79883d9acbc4abac6d2d216693f66fcc5a0bcbc1")
20+
.then((timestamp) =>
21+
assertEq(timestamp, 1687827423))
22+
.catch(console.log);
23+
}
24+
25+
testHandleOf();
26+
testLastRevokeTimestamp();

‎server-js/test/Makefile

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
build/server-js/test/TCKT.compiled-test.js: server-js/test/TCKT.compiled-test.js \
2-
server-js/TCKT.js \
1+
build/server-js/test/KPass.compiled-test.js: server-js/test/KPass.compiled-test.js \
2+
server-js/KPass.js \
33
lib/api/jsonrpc.d.js lib/api/jsonrpc.js \
4+
lib/crosschain/*.js \
45
lib/crypto/sha3.js lib/crypto/secp256k1.js lib/crypto/modular.js \
5-
lib/ethereum/eth.d.js lib/ethereum/transaction.d.js lib/ethereum/evm.js \
6+
lib/ethereum/*.js \
67
lib/testing/assert.js lib/testing/nodejs.d.js \
78
lib/util/çevir.js
89
mkdir -p $(dir $@)
@@ -20,4 +21,4 @@ build/server-js/test/TCKT.compiled-test.js: server-js/test/TCKT.compiled-test.js
2021
bun $@
2122

2223
.PHONY: server-js/test
23-
server-js/test: build/server-js/test/TCKT.compiled-test.js
24+
server-js/test: build/server-js/test/KPass.compiled-test.js

‎server-js/test/TCKT.compiled-test.js

-25
This file was deleted.

‎server-js/validator.js

+12-11
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,29 @@
66

77
import { ErrorCode, err } from "../api/error";
88
import { reportError } from "../api/validationReport";
9-
import { TCKT, TCKT_ADDR } from "./TCKT";
10-
import { TCKTSigners } from "./TCKTSigners";
9+
import { KPass } from "./KPass";
10+
import { KPassSigners } from "./KPassSigners";
11+
import { ChainId } from "/lib/crosschain/chains";
1112
import evm from "/lib/ethereum/evm";
1213

1314
/**
1415
* @constructor
1516
* @struct
1617
*
17-
* @param {!Object<string, string>} nodeUrls
18+
* @param {!Object<ChainId, string>} nodeUrls
1819
* @param {Array<string>} acceptedContracts
1920
* @param {function(!kimlikdao.Challenge):boolean=} validateChallenge
2021
* @param {boolean=} allowUnauthenticated
2122
*/
2223
function Validator(nodeUrls, acceptedContracts, validateChallenge, allowUnauthenticated) {
2324
/** @const {!Object<string, string>} */
2425
this.nodeUrls = nodeUrls;
26+
/** @const {!KPass} */
27+
this.kpass = new KPass(nodeUrls);
28+
/** @const {!KPassSigners} */
29+
this.kpassSigners = new KPassSigners(nodeUrls);
2530
/** @const {!Set<string>} */
26-
this.acceptedContracts = new Set(acceptedContracts || [TCKT_ADDR]);
27-
/** @const {!TCKT} */
28-
this.tckt = new TCKT(nodeUrls);
29-
/** @const {!TCKTSigners} */
30-
this.tcktSigners = new TCKTSigners(nodeUrls);
31+
this.acceptedContracts = new Set(acceptedContracts || this.kpass.ADDRS);
3132

3233
/**
3334
* Record the user provided challenge validator. If none provided, use the
@@ -55,12 +56,12 @@ function Validator(nodeUrls, acceptedContracts, validateChallenge, allowUnauthen
5556
Validator.prototype.validateWithAddress = function (ownerAddress, isAuthenticated, decryptedSections) {
5657
/** @const {!Array<!Promise<*>>} */
5758
const promises = [
58-
this.tckt.lastRevokeTimestamp(ownerAddress),
59+
this.kpass.lastRevokeTimestamp(ownerAddress),
5960
decryptedSections["personInfo"]
60-
? this.tckt.exposureReported(
61+
? this.kpass.exposureReported(
6162
/** @type {!did.PersonInfo} */(decryptedSections["personInfo"]).exposureReportID)
6263
: Promise.resolve(0),
63-
this.tcktSigners.validateSignersTemporary(decryptedSections, ownerAddress),
64+
this.kpassSigners.validateSignersTemporary(decryptedSections, ownerAddress),
6465
];
6566

6667
return Promise.all(promises)

0 commit comments

Comments
 (0)