Skip to content

Commit e8938fe

Browse files
committed
Enhance service verification request/response
1 parent eeb3e68 commit e8938fe

File tree

6 files changed

+83
-20
lines changed

6 files changed

+83
-20
lines changed

packages/service/gen/python/threecities/v1/transfer_verification_pb2.py

+11-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/service/proto/threecities/v1/transfer_verification.proto

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ message TransferVerificationRequest {
88
repeated string token_ticker_allowlist = 3; // allowlist of tokens to permit for a successfully verified transfer. WARNING today, not all supported tokens by 3cities are supported by 3cities on every chain (ie. the matrix of tokens * chains is incomplete), so if a ticker in tokenTickerAllowList is not available on the passed chainId, then any transfers of that token will not be detected and verification will fail as if the transfer never happened
99
double usd_per_eth = 4; // ETH price in USD exchange rate to be used when verifying logical asset amounts
1010
string receiver_address = 5; // receiver address on the passed chainId where transfer being verified is expected to have been sent
11+
string external_id = 6; // an optional external ID that may be provided by the client for tracking purposes. Not used by 3cities
1112
}
1213

1314
message UntrustedData { // from the point of view of the verification client (caller), these data are untrusted and will be verified. Verification will be successful if and only if all these untrusted data are proven to be correct and match/correspond to the trusted data. NB as always, the RPC providers used by verification are assumed to be trustworthy - clients are trusting their RPC providers to facilitate verification
@@ -31,6 +32,8 @@ message TransferVerificationResponse {
3132
bool is_verified = 1; // true iff the transfer verification was successful
3233
string description = 2; // description of verification result. Eg. if success, "0.023 ETH sent on Arbitrum One", if failure, "ChainID 3933 is not supported", "Insufficient confirmations, wanted=2, found=1"
3334
string error = 3; // optional error. Empty string indicates undefined. Always undefined if is_verified
35+
string external_id = 4; // an optional external ID that may be provided by the client for tracking purposes. Not used by 3cities
36+
bool verification_failed_permanently = 5; // true iff the verification is guaranteed to have failed permanently (eg. due to the transaction having reverted) and should not be retried. Must be ignored if is_verified
3437
}
3538

3639
service TransferVerificationService {

packages/service/src/connect.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ export default (router: ConnectRouter) =>
1818
wagmiConfig,
1919
req,
2020
});
21-
return {
21+
const resPb: TransferVerificationResponse = new TransferVerificationResponse({
2222
isVerified: res.isVerified,
2323
description: res.description,
2424
...(res.error && { error: res.error?.message } satisfies Pick<TransferVerificationResponse, 'error'>),
25-
};
25+
...(res.externalId && { externalId: res.externalId } satisfies Pick<TransferVerificationResponse, 'externalId'>),
26+
...(res.verificationFailedPermanently && { verificationFailedPermanently: res.verificationFailedPermanently } satisfies Pick<TransferVerificationResponse, 'verificationFailedPermanently'>),
27+
});
28+
console.info(`req=${reqPb.toJsonString()} resp=${resPb.toJsonString()}`);
29+
return resPb;
2630
}
2731
},
2832
});

packages/service/src/fromProto.ts

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export function transferVerificationRequestFromProto(pb: TransferVerificationReq
7676
})();
7777
const req: TransferVerificationRequest = {
7878
trusted: {
79+
...(pb.trusted.externalId.length > 0 && { externalId: pb.trusted.externalId } satisfies Pick<TransferVerificationRequest['trusted'], 'externalId'>),
7980
currency,
8081
logicalAssetAmount,
8182
tokenTickerAllowlist: pb.trusted.tokenTickerAllowlist,

packages/service/src/gen/threecities/v1/transfer_verification_pb.ts

+24
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ export class TransferVerificationRequest_TrustedData extends Message<TransferVer
9090
*/
9191
receiverAddress = "";
9292

93+
/**
94+
* an optional external ID that may be provided by the client for tracking purposes. Not used by 3cities
95+
*
96+
* @generated from field: string external_id = 6;
97+
*/
98+
externalId = "";
99+
93100
constructor(data?: PartialMessage<TransferVerificationRequest_TrustedData>) {
94101
super();
95102
proto3.util.initPartial(data, this);
@@ -103,6 +110,7 @@ export class TransferVerificationRequest_TrustedData extends Message<TransferVer
103110
{ no: 3, name: "token_ticker_allowlist", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true },
104111
{ no: 4, name: "usd_per_eth", kind: "scalar", T: 1 /* ScalarType.DOUBLE */ },
105112
{ no: 5, name: "receiver_address", kind: "scalar", T: 9 /* ScalarType.STRING */ },
113+
{ no: 6, name: "external_id", kind: "scalar", T: 9 /* ScalarType.STRING */ },
106114
]);
107115

108116
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): TransferVerificationRequest_TrustedData {
@@ -257,6 +265,20 @@ export class TransferVerificationResponse extends Message<TransferVerificationRe
257265
*/
258266
error = "";
259267

268+
/**
269+
* an optional external ID that may be provided by the client for tracking purposes. Not used by 3cities
270+
*
271+
* @generated from field: string external_id = 4;
272+
*/
273+
externalId = "";
274+
275+
/**
276+
* true iff the verification is guaranteed to have failed permanently (eg. due to the transaction having reverted) and should not be retried. Must be ignored if is_verified
277+
*
278+
* @generated from field: bool verification_failed_permanently = 5;
279+
*/
280+
verificationFailedPermanently = false;
281+
260282
constructor(data?: PartialMessage<TransferVerificationResponse>) {
261283
super();
262284
proto3.util.initPartial(data, this);
@@ -268,6 +290,8 @@ export class TransferVerificationResponse extends Message<TransferVerificationRe
268290
{ no: 1, name: "is_verified", kind: "scalar", T: 8 /* ScalarType.BOOL */ },
269291
{ no: 2, name: "description", kind: "scalar", T: 9 /* ScalarType.STRING */ },
270292
{ no: 3, name: "error", kind: "scalar", T: 9 /* ScalarType.STRING */ },
293+
{ no: 4, name: "external_id", kind: "scalar", T: 9 /* ScalarType.STRING */ },
294+
{ no: 5, name: "verification_failed_permanently", kind: "scalar", T: 8 /* ScalarType.BOOL */ },
271295
]);
272296

273297
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): TransferVerificationResponse {

0 commit comments

Comments
 (0)