Skip to content

Commit

Permalink
Merge pull request #59 from dominant-strategies/QItypes
Browse files Browse the repository at this point in the history
UTXO Types
  • Loading branch information
rileystephens28 authored Mar 29, 2024
2 parents c88189d + 5041057 commit 92d6fdf
Show file tree
Hide file tree
Showing 12 changed files with 122 additions and 133 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ output/**
**/*.tgz
dist/*.gz
/*.env
.idea/**
.idea/**
131 changes: 38 additions & 93 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"dependencies": {
"@adraffy/ens-normalize": "1.10.0",
"@brandonblack/musig": "^0.0.1-alpha.1",
"@noble/curves": "1.2.0",
"@noble/hashes": "1.3.2",
"@types/node": "18.15.13",
Expand All @@ -23,8 +24,8 @@
"description": "A complete and compact Quai library, for dapps, wallets and any other tools.",
"devDependencies": {
"@rollup/plugin-node-resolve": "15.0.2",
"@types/google-protobuf": "^3.15.12",
"@types/expect": "^24.3.0",
"@types/google-protobuf": "^3.15.12",
"@types/mocha": "^9.1.1",
"@types/semver": "7.5.0",
"axios": "^1.6.7",
Expand Down Expand Up @@ -129,4 +130,4 @@
},
"sideEffects": false,
"version": "v0.1.0-pre"
}
}
15 changes: 12 additions & 3 deletions src.ts/providers/abstract-signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,24 @@ export abstract class AbstractSigner<P extends null | Provider = null | Provider
return pop;
}

// async populateQiTransaction(tx: TransactionRequest): Promise<TransactionLike<string>> {

// }

async populateTransaction(tx: TransactionRequest): Promise<TransactionLike<string>> {
console.log("populateTransaction")
const provider = checkProvider(this, "populateTransaction");

const pop = await populate(this, tx);
if (pop.nonce == null) {
pop.nonce = await this.getNonce("pending");
}

if (pop.type == null) {
pop.type = await getTxType(pop.from ?? null, pop.to ?? null);
}

if (pop.nonce == null) {
pop.nonce = await this.getNonce("pending");
}

if (pop.gasLimit == null) {
if (pop.type == 0 ) pop.gasLimit = await this.estimateGas(pop);
else {
Expand Down Expand Up @@ -152,9 +158,12 @@ export abstract class AbstractSigner<P extends null | Provider = null | Provider
}

async sendTransaction(tx: TransactionRequest): Promise<TransactionResponse> {
console.log('sendTransaction', tx)
const provider = checkProvider(this, "sendTransaction");
const pop = await this.populateTransaction(tx);
console.log("populated tx", pop)
delete pop.from;

const txObj = Transaction.from(pop);
const signedTx = await this.signTransaction(txObj);
const result = await provider.broadcastTransaction(signedTx);
Expand Down
6 changes: 5 additions & 1 deletion src.ts/providers/formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import type { Signature } from "../crypto/index.js";
import type { AccessList } from "../transaction/index.js";

import type { UTXOTransactionInput, UTXOTransactionOutput } from "../transaction/utxo.js";

//////////////////////
// Block
Expand Down Expand Up @@ -380,6 +380,10 @@ export interface TransactionResponseParams {
* The transaction access list.
*/
accessList: null | AccessList;

outputsUTXO ?: UTXOTransactionOutput[];

inputsUTXO ?: UTXOTransactionInput[];
};


33 changes: 11 additions & 22 deletions src.ts/providers/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { AccessList, AccessListish, TransactionLike } from "../transaction/

import type { ContractRunner } from "./contracts.js";
import type { Network } from "./network.js";

import type { UTXOTransactionInput, UTXOTransactionOutput } from "../transaction/utxo.js";

const BN_0 = BigInt(0);

Expand Down Expand Up @@ -113,7 +113,6 @@ export class FeeData {
}
}


/**
* A **TransactionRequest** is a transactions with potentially various
* properties not defined, or with less strict types for its values.
Expand Down Expand Up @@ -203,16 +202,9 @@ export interface TransactionRequest {
*/
blockTag?: BlockTag;

/**
* When using ``call``, this enables CCIP-read, which permits the
* provider to be redirected to web-based content during execution,
* which is then further validated by the contract.
*
* There are potential security implications allowing CCIP-read, as
* it could be used to expose the IP address or user activity during
* the fetch to unexpected parties.
*/
enableCcipRead?: boolean;
inputs?: null | Array<UTXOTransactionInput>;

outputs?: null | Array<UTXOTransactionOutput>;
};

/**
Expand Down Expand Up @@ -304,16 +296,9 @@ export interface PreparedTransactionRequest {
*/
blockTag?: BlockTag;

/**
* When using ``call``, this enables CCIP-read, which permits the
* provider to be redirected to web-based content during execution,
* which is then further validated by the contract.
*
* There are potential security implications allowing CCIP-read, as
* it could be used to expose the IP address or user activity during
* the fetch to unexpected parties.
*/
enableCcipRead?: boolean;
inputs?: null | Array<UTXOTransactionInput>;

outputs?: null | Array<UTXOTransactionOutput>;
}

/**
Expand Down Expand Up @@ -1361,6 +1346,10 @@ export class TransactionResponse implements TransactionLike<string>, Transaction
*/
readonly accessList!: null | AccessList;

readonly inputs ?: Array<UTXOTransactionInput> ;

readonly outputs ?: Array<UTXOTransactionOutput> ;

#startBlock: number;

/**
Expand Down
Loading

0 comments on commit 92d6fdf

Please sign in to comment.