New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

scrypt-ts

Package Overview
Dependencies
Maintainers
2
Versions
178
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scrypt-ts - npm Package Compare versions

Comparing version 0.1.8-test.7 to 0.2.0-test.1

dist/client/apis/bsv-api.d.ts

7

CHANGELOG.md
# CHANGELOG
## 0.1.8-beta.1
- supports call multiple contracts, #285
- remove `transformer` in `ContractArtifact`, #287
- add js doc, #293
## 0.1.7-beta.5

@@ -5,0 +12,0 @@

7

dist/bsv/abstract-provider.d.ts

@@ -104,9 +104,2 @@ /// <reference types="node" />

}>;
/**
* Get a list of UTXO for a certain contract instance.
* @param genesisTxHash The hash value of deployment transaction of the contract instance.
* @param outputIndex The output index of the deployment transaction of the contract instance.
* @returns A promise which resolves to a list of transaction UTXO.
*/
abstract getContractUTXOs(genesisTxHash: TxHash, outputIndex: number): Promise<UTXO[]>;
readonly _isProvider: boolean;

@@ -113,0 +106,0 @@ /**

0

dist/bsv/abstract-provider.js

@@ -0,0 +0,0 @@ "use strict";

@@ -65,8 +65,2 @@ import { bsv } from 'scryptlib';

/**
* Get the connected provider.
* @returns the connected provider.
* @throws if no provider is connected to `this`.
*/
get connectedProvider(): Provider;
/**
* Connect a provider to `this`.

@@ -94,7 +88,2 @@ * @param provider The target provider.

abstract getPubKey(address?: AddressOption): Promise<bsv.PublicKey>;
listUnspent(address: AddressOption, options?: UtxoQueryOptions): Promise<UTXO[]>;
getBalance(address?: AddressOption): Promise<{
confirmed: number;
unconfirmed: number;
}>;
/**

@@ -130,4 +119,32 @@ * Sign a raw transaction hex string.

abstract getSignatures(rawTxHex: string, sigRequests: SignatureRequest[]): Promise<SignatureResponse[]>;
/**
* Get the connected provider.
* @returns the connected provider.
* @throws if no provider is connected to `this`.
*/
get connectedProvider(): Provider;
/**
* Sign transaction and broadcast it
* @param tx A transaction is signed and broadcast
* @param options The options for signing, see the details of `SignTransactionOptions`.
* @returns A promise which resolves to the transaction id.
*/
signAndsendTransaction(tx: bsv.Transaction, options?: SignTransactionOptions): Promise<TransactionResponse>;
/**
* Get a list of the P2PKH UTXOs.
* @param address The address of the returned UTXOs belongs to.
* @param options The optional query conditions, see details in `UtxoQueryOptions`.
* @returns A promise which resolves to a list of UTXO for the query options.
*/
listUnspent(address: AddressOption, options?: UtxoQueryOptions): Promise<UTXO[]>;
/**
* Get the balance of BSVs in satoshis for an address.
* @param address The query address.
* @returns A promise which resolves to the address balance status.
*/
getBalance(address?: AddressOption): Promise<{
confirmed: number;
unconfirmed: number;
}>;
/**
* Check if an object is a `Signer`

@@ -134,0 +151,0 @@ * @param value The target object

@@ -35,13 +35,8 @@ "use strict";

}
// a shortcut to provider's `listUnspent`
listUnspent(address, options) {
// default implemention using provider, can be overrided.
return this.connectedProvider.listUnspent(address, options);
}
// a shortcut to provider's `getBalance`
getBalance(address) {
// default implemention using provider, can be overrided.
return this.connectedProvider.getBalance(address);
}
// Broadcasting
/**
* Sign transaction and broadcast it
* @param tx A transaction is signed and broadcast
* @param options The options for signing, see the details of `SignTransactionOptions`.
* @returns A promise which resolves to the transaction id.
*/
signAndsendTransaction(tx, options) {

@@ -56,2 +51,21 @@ return __awaiter(this, void 0, void 0, function* () {

;
/**
* Get a list of the P2PKH UTXOs.
* @param address The address of the returned UTXOs belongs to.
* @param options The optional query conditions, see details in `UtxoQueryOptions`.
* @returns A promise which resolves to a list of UTXO for the query options.
*/
listUnspent(address, options) {
// default implemention using provider, can be overrided.
return this.connectedProvider.listUnspent(address, options);
}
/**
* Get the balance of BSVs in satoshis for an address.
* @param address The query address.
* @returns A promise which resolves to the address balance status.
*/
getBalance(address) {
// default implemention using provider, can be overrided.
return this.connectedProvider.getBalance(address);
}
// Inspection

@@ -58,0 +72,0 @@ /**

@@ -10,3 +10,3 @@ import { PublicKey, Transaction } from "bsv";

private _address;
constructor(provider?: Provider);
constructor(provider: Provider);
/**

@@ -13,0 +13,0 @@ * Check if the wallet has been authenticated

@@ -15,3 +15,2 @@ "use strict";

const abstract_signer_1 = require("../abstract-signer");
const default_provider_1 = require("../providers/default-provider");
const utils_1 = require("../utils");

@@ -22,3 +21,3 @@ // TODO: export this default value from scryptlib

constructor(provider) {
super(provider || new default_provider_1.DefaultProvider());
super(provider);
if (typeof window.sensilet !== 'undefined') {

@@ -147,2 +146,3 @@ console.log(SensiletSigner.DEBUG_TAG, 'Sensilet is installed!');

const network = yield this.getNetwork();
// Generate default `sigRequests` if not passed by user
const sigRequests = ((_a = options === null || options === void 0 ? void 0 : options.sigRequests) === null || _a === void 0 ? void 0 : _a.length) ? options.sigRequests :

@@ -164,2 +164,3 @@ tx.inputs.map((input, inputIndex) => {

const sigResponses = yield this.getSignatures(tx.toString(), sigRequests);
// Set the acquired signature as an unlocking script for the transaction
tx.inputs.forEach((input, inputIndex) => {

@@ -166,0 +167,0 @@ var _a;

@@ -0,0 +0,0 @@ import { bsv } from "scryptlib";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map

@@ -0,0 +0,0 @@ import { bsv } from 'scryptlib';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { Signer, SignatureRequest, SignatureResponse, SignTransactionOptions } from "../abstract-signer";

@@ -0,0 +0,0 @@ "use strict";

@@ -13,5 +13,5 @@ import { prop, method } from './smart-contract/decorators';

export * from './smart-contract/utils/index';
export { WhatsonchainProvider } from './bsv/providers/whatsonchain-provider';
export { DefaultProvider } from './bsv/providers/default-provider';
export { DummyProvider } from './bsv/providers/dummy-provider';
export { WhatsonchainProvider } from './providers/whatsonchain-provider';
export { DefaultProvider } from './providers/default-provider';
export { DummyProvider } from './providers/dummy-provider';
export { SensiletSigner } from './bsv/signers/sensilet-signer';

@@ -21,1 +21,2 @@ export { Provider, TransactionResponse, TxHash, ProviderEvent } from './bsv/abstract-provider';

export { TestWallet } from './bsv/wallets/test-wallet';
export { Scrypt } from './client';

@@ -17,3 +17,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.TestWallet = exports.ProviderEvent = exports.Provider = exports.SensiletSigner = exports.DummyProvider = exports.DefaultProvider = exports.WhatsonchainProvider = exports.FunctionCall = exports.buildOpreturnScript = exports.buildPublicKeyHashScript = exports.toHex = exports.bsv = exports.SmartContractLib = exports.SmartContract = exports.method = exports.prop = void 0;
exports.Scrypt = exports.TestWallet = exports.ProviderEvent = exports.Provider = exports.SensiletSigner = exports.DummyProvider = exports.DefaultProvider = exports.WhatsonchainProvider = exports.FunctionCall = exports.buildOpreturnScript = exports.buildPublicKeyHashScript = exports.toHex = exports.bsv = exports.SmartContractLib = exports.SmartContract = exports.method = exports.prop = void 0;
const decorators_1 = require("./smart-contract/decorators");

@@ -40,7 +40,7 @@ Object.defineProperty(exports, "prop", { enumerable: true, get: function () { return decorators_1.prop; } });

/* export Providers */
var whatsonchain_provider_1 = require("./bsv/providers/whatsonchain-provider");
var whatsonchain_provider_1 = require("./providers/whatsonchain-provider");
Object.defineProperty(exports, "WhatsonchainProvider", { enumerable: true, get: function () { return whatsonchain_provider_1.WhatsonchainProvider; } });
var default_provider_1 = require("./bsv/providers/default-provider");
var default_provider_1 = require("./providers/default-provider");
Object.defineProperty(exports, "DefaultProvider", { enumerable: true, get: function () { return default_provider_1.DefaultProvider; } });
var dummy_provider_1 = require("./bsv/providers/dummy-provider");
var dummy_provider_1 = require("./providers/dummy-provider");
Object.defineProperty(exports, "DummyProvider", { enumerable: true, get: function () { return dummy_provider_1.DummyProvider; } });

@@ -56,2 +56,4 @@ var sensilet_signer_1 = require("./bsv/signers/sensilet-signer");

Object.defineProperty(exports, "TestWallet", { enumerable: true, get: function () { return test_wallet_1.TestWallet; } });
var client_1 = require("./client");
Object.defineProperty(exports, "Scrypt", { enumerable: true, get: function () { return client_1.Scrypt; } });
//# sourceMappingURL=index.js.map

@@ -0,0 +0,0 @@ import { SigHashType, Ripemd160, Sha256, Sha1 } from "scryptlib";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { AbstractContract } from "scryptlib/dist";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { SupportedParamType, AbstractContract } from "scryptlib/dist";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { ByteString } from "./types";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { Flavor } from "scryptlib";

@@ -0,0 +0,0 @@ "use strict";

import "reflect-metadata";
import { bsv, ContractArtifact, VerifyResult, PubKeyHash } from "scryptlib";
import { bsv, ContractArtifact, PubKeyHash, VerifyResult } from "scryptlib";
import { ByteString, PrivKey, PubKey, Sig, SigHashPreimage, SigHashType } from "./builtins/types";

@@ -8,3 +8,3 @@ import { Provider, TransactionResponse } from "../bsv/abstract-provider";

import { TranspileError } from "../transformation/types";
import { MethodCallTxBuilder, ContractTransaction, MultiContractTransaction } from "./types/contract-call";
import { ContractTransaction, MethodCallTxBuilder, MultiContractTransaction } from "./types/contract-call";
/**

@@ -98,3 +98,3 @@ * A reference to an input of a transaction

*/
from?: TxOutputRef;
from?: TxOutputRef | UTXO;
/**

@@ -108,4 +108,2 @@ * `to` is a reference to a transaction input where a public method of `this` contract instance is called.

/** @ignore */
private _fromUTXO?;
/** @ignore */
private _currentMethod?;

@@ -130,2 +128,8 @@ /** @ignore */

static loadArtifact(artifact: ContractArtifact): void;
/**
*
* The contract class needs to call this function before instantiating.
* @param artifact a merged contract artifact object
*/
static getArtifact(): ContractArtifact;
/** @ignore */

@@ -351,5 +355,33 @@ private static _getTransformationResult;

get provider(): Provider | undefined;
/** @ignore */
private buildDeployTransaction;
/**
* creates a tx to deploy the contract. Users override it to cutomize a deployment tx as below.
* @example
* ```ts
* override async buildDeployTransaction(utxos: UTXO[], amount: number, changeAddress?: bsv.Address | string): Promise<bsv.Transaction> {
* const deployTx = new bsv.Transaction()
* // add p2pkh inputs for paying tx fees
* .from(utxos)
* // add contract output
* .addOutput(new bsv.Transaction.Output({
* script: this.lockingScript,
* satoshis: amount,
* }))
* // add the change output if passing `changeAddress`
* if (changeAddress) {
* deployTx.change(changeAddress);
* if (this._provider) {
* deployTx.feePerKb(await this.provider.getFeePerKb());
* }
* }
*
* return deployTx;
* }
* ```
* @param utxos represents one or more P2PKH inputs for paying transaction fees.
* @param amount the balance of contract output
* @param changeAddress a change address
* @returns
*/
buildDeployTransaction(utxos: UTXO[], amount: number, changeAddress?: bsv.Address | string): Promise<bsv.Transaction>;
/**
* Deploy the contract

@@ -356,0 +388,0 @@ * @param amount satoshis locked in the contract

@@ -0,0 +0,0 @@ import { SigHashType } from "scryptlib";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import "reflect-metadata";

@@ -0,0 +0,0 @@ "use strict";

@@ -40,3 +40,3 @@ import { bsv } from "scryptlib";

/** Whether to call multiple contracts at the same time in one transaction */
readonly multiContractCall?: true;
readonly multiContractCall?: boolean;
/** Pass the `ContractTransaction` of the previous call as an argument to the next call, only used if `multiContractCall = true`. */

@@ -43,0 +43,0 @@ readonly partialContractTransaction?: ContractTransaction;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=contract-call.js.map
export * from './contract-call';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { bsv } from 'scryptlib';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { bsv } from "scryptlib";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { Range } from './types';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import * as ts from 'typescript';

@@ -0,0 +0,0 @@ "use strict";

@@ -70,2 +70,4 @@ import * as ts from 'typescript';

private isExtendsSCComponent;
private isContract;
private isLibrary;
/**

@@ -72,0 +74,0 @@ * check if the filepath is in `tsRootDir`

@@ -0,0 +0,0 @@ import ts from "typescript";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import * as ts from 'typescript';

@@ -0,0 +0,0 @@ "use strict";

{
"name": "scrypt-ts",
"version": "0.1.8-test.7",
"version": "0.2.0-test.1",
"description": "A toolset for building sCrypt smart contract applications on Bitcoin SV network written in typescript.",

@@ -14,3 +14,4 @@ "main": "dist/index.js",

"pretest": "npm run build && npm run clean-test-out && cross-env TS_NODE_PROJECT=test/tsconfig.json NODE_ENV=test tsc -p test",
"test": "cd test && mocha 'out/test/local/**/*.test.js' --timeout 1200000",
"test": "cd test && mocha 'out/test/local/**/*.test.js' 'out/test/client/**/*.test.js' --timeout 1200000",
"testclient": "npm run pretest && cd test && mocha 'out/test/client/**/*.test.js' --timeout 1200000",
"pretestnet": "npm run pretest",

@@ -38,2 +39,3 @@ "testnet": "cd test && mocha out/test/testnet/*.js --timeout 1200000",

"@types/object-hash": "^3.0.2",
"@types/superagent": "^4.1.16",
"bigint-rnd": "^1.0.2",

@@ -47,2 +49,3 @@ "chai": "^4.3.6",

"mocha": "^10.1.0",
"msw": "^1.1.0",
"npm": "^9.1.3",

@@ -56,2 +59,3 @@ "rimraf": "^3.0.2",

"@phenomnomnominal/tsquery": "^5.0.0",
"deep-equal": "^2.2.0",
"fast-diff": "^1.2.0",

@@ -58,0 +62,0 @@ "lodash": "^4.17.21",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc